/* === RESET ET BASE === */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #1B5E20; /* Vert foncé comme dans l'image */
  color: #E8F5E8;
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}

/* ========== POPUP ERREUR PREMIÈRE POSE ========== */
.first-lay-error-popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.first-lay-error-popup.visible {
  opacity: 1;
  visibility: visible;
}

.first-lay-error-popup .error-content {
  background: linear-gradient(135deg, #c62828, #b71c1c);
  border-radius: 16px;
  padding: 30px 40px;
  max-width: 450px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.first-lay-error-popup.visible .error-content {
  transform: scale(1);
}

.first-lay-error-popup .error-icon {
  font-size: 60px;
  margin-bottom: 15px;
}

.first-lay-error-popup .error-title {
  font-size: 20px;
  font-weight: bold;
  color: white;
  margin: 0 0 15px 0;
}

.first-lay-error-popup .error-details {
  font-size: 15px;
  color: rgba(255,255,255,0.9);
  margin: 0 0 25px 0;
  line-height: 1.5;
}

.first-lay-error-popup .error-close-btn {
  background: white;
  color: #c62828;
  border: none;
  padding: 12px 40px;
  font-size: 16px;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s;
}

.first-lay-error-popup .error-close-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Disable text selection on game elements */
.game-container, .action-bar, .player-seat, .card {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* === UTILITIES === */
.hidden { display: none !important; }

/* Mise en évidence des groupes invalides lors de la première pose */
.staging-group.invalid-group {
  outline: 3px solid #f44336;
  box-shadow: 0 0 0 4px rgba(244,67,54,0.35);
  position: relative;
}
.staging-group.invalid-group::after {
  content: 'Invalide';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  background: #f44336;
  color: #fff;
  padding: 2px 6px;
  border-radius: 10px;
  letter-spacing: .5px;
  font-weight: 600;
  text-transform: uppercase;
  pointer-events: none;
}

.primary {
  background: linear-gradient(135deg, #4CAF50, #66BB6A);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary:hover {
  background: linear-gradient(135deg, #45a049, #5da961);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.secondary {
  background: rgba(255,255,255,0.1);
  color: #E8F5E8;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary:hover {
  background: rgba(255,255,255,0.15);
}

/* === HEADER === */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  min-height: 48px;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.phase-info {
  text-align: center;
  font-size: 13px;
  color: #C8E6C9;
}

.turn-info {
  display: block;
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

.header-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #E8F5E8;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.header-btn:hover {
  background: rgba(255,255,255,0.2);
}



.game-code-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-code {
  font-family: 'Courier New', monospace;
  font-weight: bold;
  background: rgba(76, 175, 80, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.share-btn {
  background: linear-gradient(135deg, #2196F3, #42A5F5);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.share-btn:hover {
  background: linear-gradient(135deg, #1976D2, #1E88E5);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.info-toggle.active {
  background: rgba(76, 175, 80, 0.4);
}

/* === INFO PANEL === */
.info-panel {
  background: rgba(0,0,0,0.2);
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}

.info-row {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* === POPUP SALLE === */
.room-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.popup-content {
  background: #2E7D32;
  border-radius: 12px;
  padding: 24px;
  min-width: 320px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Scroll personnalisé pour le popup */
.popup-content::-webkit-scrollbar {
  width: 8px;
}

.popup-content::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
  border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.3);
  border-radius: 4px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.5);
}

.popup-content h3 {
  margin: 0 0 20px 0;
  color: #E8F5E8;
  text-align: center;
  font-size: 18px;
}

.popup-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.popup-hint {
  margin: 8px 0 0 0;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  text-align: center;
}

.popup-section:last-of-type {
  border-bottom: none;
}

.popup-section label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: #C8E6C9;
}

.popup-section input, .popup-section select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(0,0,0,0.2);
  color: #E8F5E8;
  font-size: 14px;
  margin-bottom: 12px;
}

.popup-section input:focus, .popup-section select:focus {
  outline: none;
  border-color: #4CAF50;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.popup-section h4 {
  margin: 0 0 12px 0;
  color: #A5D6A7;
  font-size: 14px;
}

.reconnect-section {
  margin-top: 15px;
  padding: 15px;
  background: rgba(0,0,0,0.1);
  border-radius: 8px;
  text-align: center;
}

.reconnect-section p {
  margin: 0 0 10px 0;
  color: #A5D6A7;
  font-size: 13px;
}

.reconnect-section hr {
  border: none;
  height: 1px;
  background: #666;
  margin: 10px 0;
}

/* === TURN NOTIFICATION === */
.turn-notification {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #FF9800, #F57C00);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: bold;
  box-shadow: 0 4px 16px rgba(255, 152, 0, 0.4);
  z-index: 1500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* === GAME CONTAINER === */
.game-container {
  min-height: calc(100vh - 48px);
  position: relative;
}

/* === WELCOME SCREEN === */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 48px);
  padding: 20px;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
}

.welcome-content h1 {
  font-size: 24px;
  margin: 0 0 16px 0;
  color: #E8F5E8;
}

.welcome-content p {
  font-size: 16px;
  color: #C8E6C9;
  margin: 0 0 20px 0;
}

.status-info {
  padding: 12px 20px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  font-size: 14px;
}

/* === LOBBY VIEW === */
.lobby-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 48px);
  padding: 20px;
}

.lobby-content {
  text-align: center;
  background: rgba(0,0,0,0.2);
  padding: 30px;
  border-radius: 12px;
  min-width: 300px;
}

.lobby-content h2 {
  margin: 0 0 20px 0;
  color: #E8F5E8;
}

.players-list {
  margin: 20px 0;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 4px 0;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
}

.start-btn {
  margin-top: 20px;
  font-size: 16px;
  padding: 14px 28px;
}

/* === GAME TABLE === */
.game-table {
  position: relative;
  width: 100%;
  height: calc(100vh - 96px);
  padding: 20px;
  display: grid;
  grid-template-areas: 
    ". top ."
    "left center right"
    ". bottom .";
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 50px 1fr 50px;
  gap: 20px;
}

/* === PLAYER SEATS === */
.player-seat {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.1);   /* Fond encore plus discret */
  border-radius: 2px;  /* Encore plus petit */
  padding: 2px;       /* Minimal */
  border: 1px solid transparent;
  transition: border-color 0.3s ease;
  font-size: 7px;     /* Très petit */
  line-height: 1.2;   /* Compact */
}

.player-seat.active {
  border-color: #FF9800;
  background: rgba(255, 152, 0, 0.1);
}

.player-seat.top {
  grid-area: top;
  justify-content: center;
}

.player-seat.left {
  grid-area: left;
  flex-direction: column;
}

.player-seat.right {
  grid-area: right;
  flex-direction: column;
}

.player-seat.bottom {
  grid-area: bottom;
  flex-direction: column;
  align-items: center;
  padding: 2px 1px;  /* Encore plus petit */
}

.player-info {
  text-align: center;
  margin-bottom: 1px;  /* Encore plus petit */
}

.player-name {
  font-weight: bold;
  font-size: 6px;      /* Très très petit */
  color: #E8F5E8;
}

.player-cards {
  font-size: 12px;
  color: #A5D6A7;
  margin-top: 2px;
}

.player-status {
  font-size: 11px;
  color: #FFCC02;
  margin-top: 4px;
}

/* === CENTER ZONE === */
.center-zone {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
}

/* === PILES AREA === */
.piles-area {
  display: flex;
  gap: 60px;          /* Augmenté de 20px à 60px pour espacer pioche/défausse */
  align-items: center;
}

.pile-container {
  position: relative;
  margin: 0 10px;     /* Ajouter marge horizontale pour éviter collision */
}

.pile {
  width: 70px;
  height: 98px;  /* ratio 1:1.4 */
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.pile:hover {
  border-color: #4CAF50;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.pile.deck {
  background: #1565C0;
}

.card-back {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1976D2, #1565C0);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.card-back::before {
  content: '🂠';
}

.pile-counter {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.pile.discard {
  background: rgba(255,255,255,0.1);
  border-style: dashed;
  cursor: pointer;
  pointer-events: auto !important;
  touch-action: manipulation;
}

.pile.deck {
  cursor: pointer;
  pointer-events: auto !important;
  touch-action: manipulation;
}

.discard-card {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto !important;
}

.discard-card:hover {
  transform: scale(1.05);
}

.discard-card .card {
  margin: 0;
  position: relative;
}

/* === SUPPORT TACTILE === */
.card {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* DÉSACTIVÉ: Ne jamais modifier les cartes au clic/touch pour éviter le saut au centre */
.card:active,
#handFan .card:active,
.hand-fan .card:active,
.hand-card:active {
  /* Neutralisé - le transform est géré uniquement par JavaScript via Pointer Events */
  pointer-events: auto; /* Garde juste les events */
}

.dragging-touch {
  opacity: 0.3 !important;
  transform: scale(0.9) !important;
}

.pile.deck, .discard-card {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  cursor: pointer;
  pointer-events: auto !important;
}

.pile.deck:active, .discard-card:active {
  transform: scale(0.95);
}

/* Force les piles à être cliquables */
#deckPile, #discardPile, #discardTop {
  cursor: pointer !important;
  pointer-events: auto !important;
  z-index: 100;
}

/* Boutons tactiles */
button, .btn, .primary, .secondary {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  min-height: 44px; /* Taille minimum recommandée Apple/Google */
  min-width: 44px;
}

button:active, .btn:active, .primary:active, .secondary:active {
  transform: scale(0.95);
}

/* Amélioration des zones de drop pour mobile */
@media (max-width: 768px) {
  .meld, .staging-area, .drop-zone {
    min-height: 60px;
    padding: 10px;
  }
  
  .card {
    margin: 2px;
  }
  
  /* Espacement des piles sur mobile */
  .piles-area {
    gap: 30px;  /* Espacement réduit pour mobile */
    padding: 10px;  /* Padding pour zone de drop plus grande */
  }
  
  .pile-container {
    margin: 0 5px;  /* Marge réduite sur mobile */
  }
  
  /* Zones de drop standard sur mobile */
  .pile {
    min-width: 80px;
    min-height: 112px;
  }
  
  .action-btn {
    min-height: 48px;
    font-size: 14px;
    padding: 12px 16px;
  }
  
  /* Popup optimisé pour mobile */
  .popup-content {
    max-width: 95vw;
    max-height: 85vh;
    padding: 20px;
    margin: 10px;
  }
  
  .popup-section {
    margin-bottom: 15px;
    padding-bottom: 12px;
  }
}

/* Très petits écrans (smartphones portrait) */
@media (max-width: 480px) {
  .popup-content {
    max-width: 98vw;
    max-height: 80vh;
    padding: 16px;
    margin: 5px;
    min-width: unset;
  }
  
  .popup-content h3 {
    font-size: 16px;
    margin-bottom: 16px;
  }
  
  .popup-section {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  
  .popup-section input,
  .popup-section select,
  .popup-section button {
    font-size: 16px; /* Empêche le zoom sur iOS */
  }
}

.pile-label {
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: #A5D6A7;
  white-space: nowrap;
}

/* === MELDS ZONE === */
.melds-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  max-width: 100%;
}

.meld {
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  gap: 4px;
  min-height: 60px;
  align-items: center;
  border: 1px solid rgba(255,255,255,0.1);
  position: relative;
  transition: all 0.3s ease;
}

.meld:hover {
  background: rgba(76, 175, 80, 0.1);
  border-color: #4CAF50;
}

.meld-drop-zone {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: #A5D6A7;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.meld:hover .meld-drop-zone {
  opacity: 1;
}

.meld-add-zone {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 10px;
  color: #4CAF50;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  background: rgba(0,0,0,0.7);
  padding: 2px 4px;
  border-radius: 4px;
}

.meld:hover .meld-add-zone {
  opacity: 1;
}

.meld.drag-over {
  background: rgba(76, 175, 80, 0.3) !important;
  border-color: #4CAF50 !important;
  transform: scale(1.02);
}

.meld-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  color: #A5D6A7;
  text-transform: uppercase;
}

/* === HAND FAN === */
.hand-fan {
  width: 70%;
  height: 200px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible; /* Permet aux cartes de dépasser vers le haut uniquement */
}

/* Conteneur pour éviter le débordement horizontal */
.hand-fan .card {
  position: relative;
  /* Les cartes dans l'éventail utilisent maintenant les tailles définies plus bas */
}

/* === CARDS === */
.card {
  width: 70px;   /* Taille réduite */
  height: 98px;  /* Proportion 1:1.4 (ratio carte standard) */
  min-width: 50px;   
  min-height: 70px;
  max-width: 100px;  
  max-height: 140px;
  background: white;
  border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: absolute;
  transform-origin: bottom center;
  font-weight: bold;
}

.card:hover {
  transform: translateY(-8px);
  z-index: 5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ANCIENNE CLASSE .selected SUPPRIMÉE - Utiliser .is-selected à la place */

.card.selected-for-lay {
  border-color: #4CAF50;
  background: #E8F5E8;
}

.card-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: space-between;
}

.card .rank {
  position: absolute;
  top: 1px;
  left: 1px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.card .suit {
  position: absolute;
  bottom: 1px;
  right: 1px;
  font-size: 18px;
  line-height: 1;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Couleurs des cartes */
.card.heart, .card.diamond {
  color: #D32F2F;
}

.card.club, .card.spade {
  color: #212121;
}

.card.joker {
  background: linear-gradient(135deg, #9C27B0, #673AB7);
  color: white;
}

/* Cartes miniatures pour les autres joueurs */
.card.mini {
  width: 30px;
  height: 42px;
  font-size: 8px;
}

.card.tiny {
  width: 40px;
  height: 56px;
  font-size: 10px;
}

/* === ACTION BAR === */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.9);
  backdrop-filter: blur(10px);
  padding: 12px 20px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  z-index: 1000;
  border-top: 1px solid rgba(255,255,255,0.1);
  /* iOS safe area */
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: #E8F5E8;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 90px;
  white-space: nowrap;
}

.action-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.25);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Highlight SANS animation pour éviter le décalage */
.action-btn.highlight {
  background: linear-gradient(135deg, #FF9800, #F57C00) !important;
  border-color: #FF9800 !important;
  /* PAS d'animation - ça cause des décalages */
}



/* === STAGING AREA === */
.staging-area {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.95);
  z-index: 2000;
  padding: 20px;
  overflow-y: auto;
}

.staging-header {
  text-align: center;
  margin-bottom: 20px;
}

.staging-header h3 {
  color: #E8F5E8;
  margin: 0 0 8px 0;
}

.staging-header p {
  color: #A5D6A7;
  font-size: 14px;
  margin: 0;
}

.staging-groups {
  display: flex;
  flex-direction: row; /* horizontal */
  flex-wrap: nowrap;
  gap: 16px;
  margin-bottom: 20px;
  min-height: 200px;
  justify-content: center; /* centre la première rangée */
  align-items: flex-start;
  overflow-x: auto;
  padding: 8px 4px;
}

.staging-group {
  background: rgba(255,255,255,0.1);
  border: 2px dashed rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 12px;
  min-height: 100px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex: 0 0 auto; /* ne pas étirer, conserver largeur auto */
  cursor: pointer;
  transition: all 0.2s ease;
}

.staging-group:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(76, 175, 80, 0.5);
}

.staging-group:active {
  transform: scale(0.98);
}

/* Correctifs visibilité cartes staging */
.staging-group .card {
  position: relative !important;
  opacity: 1 !important;
  transform: none !important;
  left: 0 !important;
  top: 0 !important;
  rotate: 0deg !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.staging-group .card.small, .staging-group .card.mini, .staging-group .card.tiny {
  width: 50px;
  height: 70px;
  font-size: 10px;
}

.staging-group.selected {
  outline: 2px solid #4CAF50;
  box-shadow: 0 0 0 3px rgba(76,175,80,0.3) inset;
}

.group-cards em { color:#A5D6A7; font-size:12px; }

.staging-group.empty {
  justify-content: center;
  color: #A5D6A7;
  font-style: italic;
}

.staging-card {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.staging-card:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
  border-color: #FFC107 !important;
}

.staging-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.staging-btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.staging-btn.validate {
  background: linear-gradient(135deg, #4CAF50, #66BB6A);
  color: white;
}

.staging-btn.cancel {
  background: #F44336;
  color: white;
}

.staging-info {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 14px;
}

.points-counter {
  color: #E8F5E8;
  font-weight: bold;
}

.rules-check {
  color: #FFCC02;
}

/* === ROUND OVERLAY === */
.round-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
}

.round-content {
  background: #2E7D32;
  border-radius: 12px;
  padding: 30px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}

.round-winner {
  font-size: 18px;
  margin: 16px 0;
  color: #FFCC02;
  font-weight: bold;
}

.scores-table {
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
}

.round-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.round-btn {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

/* === SCROLL TO HAND === */
.scroll-to-hand {
  position: fixed;
  bottom: 100px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(76, 175, 80, 0.9);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 1000;
}

/* === TOASTS === */
.toasts-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: rgba(0,0,0,0.9);
  color: white;
  padding: 12px 16px;
  border-radius: 8px;
  max-width: 300px;
  word-wrap: break-word;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success {
  border-left: 4px solid #4CAF50;
}

.toast.error {
  border-left: 4px solid #F44336;
}

.toast.warning {
  border-left: 4px solid #FF9800;
}

/* === LOGS SYSTEM SUPPRIMÉ === */
/* Les logs sont maintenant dans logs.html - plus de bannière intégrée */

/* === POPUPS RÉSULTATS === */
.round-scores {
  margin: 15px 0;
}

.score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  margin: 8px 0;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border-left: 4px solid #666;
}

.score-entry.winner {
  background: rgba(76, 175, 80, 0.1);
  border-left-color: #4CAF50;
}

.score-entry.penalty {
  background: rgba(244, 67, 54, 0.1);
  border-left-color: #f44336;
}

.score-entry .player-name {
  font-weight: bold;
  flex: 1;
}

.score-entry .score-details {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.score-entry .round-score {
  font-size: 18px;
  font-weight: bold;
}

.score-entry .total-score {
  font-size: 12px;
  opacity: 0.7;
}

.score-breakdown {
  font-size: 11px;
  opacity: 0.6;
  text-align: right;
}

.total-scores {
  margin: 15px 0;
}

.total-score-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  margin: 8px 0;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
}

.total-score-entry.game-winner {
  background: rgba(255, 193, 7, 0.2);
  border: 2px solid #FFC107;
  color: #FFC107;
}

.total-score-entry.game-loser {
  background: rgba(244, 67, 54, 0.1);
  border-left: 4px solid #f44336;
}

/* === CLASSES UTILITAIRES === */
.hidden {
  display: none !important;
}

.show {
  display: flex !important;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .game-table {
    grid-template-areas: 
      "top"
      "center"
      "bottom";
    grid-template-rows: auto 1fr auto;
    grid-template-columns: 1fr;
    padding: 10px;
  }
  
  .player-seat.left,
  .player-seat.right {
    position: absolute;
    top: 70px;      /* En haut, sous le header, pas au milieu */
    transform: none;
    width: 45px;    /* Encore plus petit */
    height: 30px;   /* Encore plus petit */
    font-size: 6px; /* Très très petit */
    z-index: 10;    /* Ne pas bloquer les melds */
  }
  
  .player-seat.left {
    left: 5px;
  }
  
  .player-seat.right {
    right: 5px;
  }
  
  .action-bar {
    padding: 8px 12px;
    gap: 6px;
  }
  
  .action-btn {
    min-width: 60px;
    padding: 6px 8px;
  }
  
  .card {
    width: 45px;
    height: 63px;
  }
  
  .hand-fan {
    height: 80px;
  }
}

/* Responsive simple sans effets de saut */
@media (max-width: 800px) {
  .hand-fan {
    width: 95%;
  }
  
  .action-btn {
    font-size: 12px;
    padding: 10px 14px;
  }
}

/* === DRAG & DROP === */
.card.dragging {
  opacity: 0.7;
  transform: rotate(5deg) scale(1.1);
  z-index: 1000;
}

.drop-zone {
  border: 2px dashed #4CAF50;
  background: rgba(76, 175, 80, 0.1);
}

.drop-zone.invalid {
  border-color: #F44336;
  background: rgba(244, 67, 54, 0.1);
}

/* === DRAG & DROP DESKTOP (HTML5) === */
.card.drag {
  opacity: 0.55;
  outline: 2px dashed #4CAF50;
  filter: grayscale(0.2);
}

.dropzone.dragover {
  outline: 2px dashed #4CAF50;
  background: rgba(46, 229, 140, 0.08);
}

/* Caret d'insertion pour réorganisation */
.caret {
  width: 3px;
  background: #4CAF50;
  border-radius: 3px;
  align-self: stretch;
  margin: 0 2px;
  animation: blinkCaret 1s linear infinite;
}

@keyframes blinkCaret {
  0%, 60% { opacity: 1; }
  70% { opacity: 0.2; }
  100% { opacity: 1; }
}

/* Défausse avec effet aimant */
#discardTop.magnet,
.discard-card.magnet {
  box-shadow: 0 0 0 4px rgba(46, 229, 140, 0.35), 0 0 18px -2px rgba(46, 229, 140, 0.6);
  transform: scale(1.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Support drag natif pour main */
.hand-card[draggable="true"] {
  cursor: grab;
}

.hand-card[draggable="true"]:active {
  cursor: grabbing;
}

/* === DRAG & DROP MOBILE TACTILE === */

/* Carte en cours de drag tactile */
.card.dragging-touch {
  position: fixed !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  opacity: 0.9 !important;
  transform: scale(1.15) rotate(5deg) !important;
  transition: none !important;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5) !important;
}

/* Placeholder pour montrer d'où vient la carte */
.card.drag-placeholder {
  opacity: 0.3 !important;
  border: 2px dashed #4CAF50 !important;
  background: rgba(76, 175, 80, 0.1) !important;
}

/* Zone de drop active */
.drop-zone-active {
  animation: pulseDropZone 1s ease-in-out infinite !important;
  outline: 3px solid #4CAF50 !important;
  background: rgba(46, 229, 140, 0.15) !important;
}

@keyframes pulseDropZone {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.03);
    opacity: 0.8;
  }
}

/* Feedback visuel pour zone de drop valide */
.drop-zone-valid {
  background: rgba(76, 175, 80, 0.2) !important;
  border-color: #4CAF50 !important;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4) !important;
}

/* Feedback pour zone invalide */
.drop-zone-invalid {
  background: rgba(244, 67, 54, 0.2) !important;
  border-color: #f44336 !important;
  box-shadow: 0 0 20px rgba(244, 67, 54, 0.4) !important;
}

/* Indicateur de position d'insertion mobile */
.mobile-insert-indicator {
  position: absolute;
  width: 4px;
  background: linear-gradient(180deg, transparent, #4CAF50, transparent);
  border-radius: 2px;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
  animation: blinkIndicator 0.8s ease-in-out infinite;
}

@keyframes blinkIndicator {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Amélioration tactile des zones de drop */
@media (hover: none) and (pointer: coarse) {
  .pile.discard,
  .discard-card,
  .meld {
    min-height: 100px !important;
    min-width: 80px !important;
  }
  
  /* Feedback tactile */
  .card {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
  }
}

/* === ANIMATIONS === */
.card-deal {
  animation: dealCard 0.5s ease;
}

@keyframes dealCard {
  from {
    transform: translateY(-200px) rotate(180deg);
    opacity: 0;
  }
  to {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
}

.meld-reorganize {
  animation: reorganize 0.3s ease;
}

@keyframes reorganize {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Font variant for "10" cards */
.card .rank {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

/* === MOBILE PORTRAIT MODE FIXES === */
@media (max-width: 768px) and (orientation: portrait) {
  .action-bar {
    position: relative; /* au lieu de fixed pour éviter chevauchement */
    padding: 8px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 10px;
    margin: 10px;
  }
  
  .hand-container {
    margin-bottom: 80px; /* plus d'espace pour boutons */
    padding-bottom: 20px;
  }
  
  #player-hand {
    margin-bottom: 20px; /* espace supplémentaire entre cartes et boutons */
  }
  
  /* Ajuster la taille des boutons pour mobile portrait */
  .action-bar button {
    padding: 12px 16px;
    margin: 4px;
    font-size: 14px;
    min-height: 44px; /* taille tactile recommandée */
  }
  
  /* S'assurer que les cartes ne dépassent pas */
  .card {
    margin-bottom: 10px;
  }
  
  /* Réduire la hauteur de la zone de jeu si nécessaire */
  body {
    padding-bottom: 120px; /* espace en bas pour interface */
  }
}

/* === MOBILE TOUCH IMPROVEMENTS === */
@media (max-width: 768px) {
  .staging-group {
    min-height: 150px; /* plus grand sur mobile */
    padding: 15px;
    margin-bottom: 15px;
  }
  
  /* Zones de drop plus grandes pour mobile */
  .staging-group.empty {
    min-height: 120px;
    font-size: 14px;
  }
}

/* Ta main avec taille raisonnable */
.hand-fan {
  width: 85%;          /* Largeur raisonnable */
  height: 180px;       /* Hauteur fixe plus fiable */
}

/* N’agrandit que les cartes de TA main (pas la pioche ni les autres joueurs) */
.hand-fan .card {
  width: 100px;        /* Taille fixe pour la main */
  height: 125px;       /* Proportion 4:5 */
  min-width: 80px;     
  min-height: 100px;
  max-width: 130px;    
  max-height: 162px;
}

/* Ajuste la typo des coins pour taille raisonnable */
.hand-fan .card .rank { font-size: 16px; }  /* Taille raisonnable */
.hand-fan .card .suit { font-size: 20px; }  /* Taille raisonnable */

/* Media queries vraiment responsives */
@media (max-width: 1200px) {
  .hand-fan .card { 
    width: 90px; 
    height: 112px; 
  }
  .hand-fan .card .rank { font-size: 15px; }
  .hand-fan .card .suit { font-size: 18px; }
}
@media (max-width: 768px) {
  /* AMÉLIORATION LAYOUT MOBILE */
  .game-container {
    padding: 5px;
    gap: 8px;
  }
  
  .hand-fan { 
    height: 140px;       /* Hauteur réduite pour mobile */
    width: 95%;          
  }
  
  .hand-fan .card { 
    width: 80px;         /* Taille fixe mobile */
    height: 100px;       
  }
  
  .hand-fan .card .rank { font-size: 12px; }
  .hand-fan .card .suit { font-size: 16px; }
  
  /* Zones de drop plus grandes sur mobile */
  .meld, .staging-group {
    min-height: 70px !important;
    border-width: 2px !important;
  }
  
  /* Boutons tactiles */
  .action-bar button {
    min-height: 44px !important;
    font-size: 14px !important;
    padding: 10px 16px !important;
  }
}
@media (max-width: 480px) {
  .hand-fan { 
    height: 120px;       /* Plus compact pour petits écrans */
    width: 98%; 
  }
  
  .hand-fan .card { 
    width: 70px;         /* Cartes plus petites sur très petits écrans */
    height: 87px;        
  }
  
  .hand-fan .card .rank { font-size: 10px; }
  .hand-fan .card .suit { font-size: 13px; }
  
  /* Interface ultra-compacte */
  .game-header {
    padding: 4px 8px;
    min-height: 40px;
  }
  
  .header-center {
    margin-top: 2px; /* empêche overlap du texte phase sur boutons */
  }
  
  .action-bar {
    padding: 6px;
    gap: 6px;
  }
  
  .action-bar button {
    min-height: 40px !important;
    font-size: 12px !important;
    padding: 8px 12px !important;
  }
  
  /* Piles compactes */
  .piles-area {
    gap: 20px;
    padding: 10px;
  }
}

/* === MOBILE-SPECIFIC STYLES === */

/* Bouton de défausse mobile */
.mobile-discard-button {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: linear-gradient(135deg, #f44336, #e53935);
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 8px 24px rgba(244, 67, 54, 0.5);
  cursor: pointer;
  animation: pulse 2s infinite;
  min-width: 200px;
  display: none;
}

.mobile-discard-button:active {
  transform: translateX(-50%) scale(0.95);
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* Amélioration tactile générale - SANS forcer la taille des cartes */
@media (hover: none) and (pointer: coarse) {
  /* NE PAS forcer la taille des cartes - laisser les autres CSS gérer */
  .card {
    touch-action: manipulation;
  }
  
  button, .btn {
    min-height: 44px !important;
    min-width: 44px !important;
    touch-action: manipulation;
  }
  
  /* Désactiver le hover sur tactile */
  .card:hover {
    transform: none !important;
  }
  
  /* Meilleur feedback visuel sur tap */
  .card:active {
    opacity: 0.8;
  }
  
  button:active, .btn:active {
    opacity: 0.8;
  }
}

/* Éviter les problèmes de zoom sur mobile */
@media (max-width: 768px) {
  input, select, textarea, button {
    font-size: 16px !important; /* Empêche le zoom automatique sur iOS */
  }
}

/* Mode paysage mobile */
@media (max-width: 896px) and (orientation: landscape) {
  .game-container {
    padding: 3px;
  }
  
  .hand-fan {
    height: 100px;
  }
  
  .hand-fan .card {
    width: 60px;
    height: 75px;
  }
  
  .game-header {
    min-height: 32px;
    padding: 2px 8px;
  }
  
  .action-bar {
    padding: 4px;
    gap: 4px;
  }
}

/* === BOTTOM SHEET - POSER 1 FOIS (Mobile-first) === */
.staging-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55vh; /* Hauteur fixe */
  background: #2E7D32;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 500;
  touch-action: none;
}

.staging-sheet:not(.hidden) {
  transform: translateY(0);
}

/* Quand la sheet est ouverte, déplacer la zone de main vers le haut */
body.staging-active .player-seat.bottom {
  transform: translateY(-48vh);
  transition: transform 300ms ease;
}

/* CACHER la barre d'actions pendant le staging */
body.staging-active #actionBar {
  display: none !important;
}

/* PC: main en premier plan au-dessus du staging sheet */
body.staging-active #handFan {
  z-index: 800 !important; /* AU-DESSUS du staging-sheet (500) */
  position: relative;
}

/* Les cartes de la main doivent être cliquables au-dessus du staging */
body.staging-active #handFan .card {
  pointer-events: auto;
  cursor: pointer;
}

.sheet-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet-header h3 {
  margin: 0;
  font-size: 18px;
  color: #E8F5E8;
}

.points-display {
  font-size: 18px;
  font-weight: bold;
  color: #FFD54F;
}

.points-required {
  font-size: 12px;
  opacity: 0.7;
  margin-left: 4px;
}

.close-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.close-btn:hover {
  background: rgba(255,255,255,0.2);
}

.sheet-body {
  overflow-y: auto;
  padding: 12px 16px;
  overscroll-behavior: contain;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.sheet-header {
  flex-shrink: 0;
}

.staging-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0; /* Ne pas réduire les boutons */
}

.staging-actions button {
  flex: 1;
  background: rgba(76, 175, 80, 0.3);
  border: 1px solid rgba(76, 175, 80, 0.5);
  color: white;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.staging-actions button:hover {
  background: rgba(76, 175, 80, 0.5);
}

.staging-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  max-height: calc(55vh - 200px); /* Hauteur sheet - header - footer - actions */
  padding-right: 4px;
}

.staging-group {
  background: rgba(0,0,0,0.2);
  border: 2px dashed rgba(255,255,255,0.3);
  border-radius: 8px;
  padding: 8px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: pan-x pan-y;
  transition: all 0.2s;
  flex-shrink: 0;
}

.staging-group .group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}

.staging-group .group-label {
  font-size: 12px;
  font-weight: bold;
  color: #fff;
}

.staging-group .group-points {
  font-size: 14px;
  font-weight: bold;
  color: #FFD700;
  padding: 2px 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
}

.staging-group .group-delete-btn {
  background: rgba(244, 67, 54, 0.7);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.staging-group .group-delete-btn:hover {
  background: #F44336;
  transform: scale(1.1);
}

.staging-group .group-cards {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 50px;
}

.staging-group.valid {
  border-color: #4CAF50;
  border-style: solid;
  background: rgba(76, 175, 80, 0.1);
}

.staging-group.invalid {
  border-color: #F44336;
  border-style: solid;
  background: rgba(244, 67, 54, 0.1);
}

.staging-group--dropzone-active,
.staging-group.dropzone--active {
  background: rgba(76, 175, 80, 0.3);
  border-style: solid;
  border-color: #FFD54F;
  box-shadow: 0 0 0 4px rgba(255, 213, 79, 0.3);
}

.group-placeholder {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  font-style: italic;
  padding: 8px;
}

.staging-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  text-align: center;
  padding: 8px;
  font-style: italic;
}

.sheet-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex !important;
  gap: 12px;
  background: #1B5E20;
  flex-shrink: 0 !important;
  min-height: 60px;
  position: relative;
  z-index: 9999; /* TRÈS HAUT pour être sûr qu'il est cliquable */
  pointer-events: auto !important; /* FORCER les événements */
}

.btn-cancel {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 14px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.btn-validate {
  flex: 1;
  background: linear-gradient(135deg, #4CAF50, #66BB6A);
  color: white;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  min-height: 48px;
  cursor: pointer;
  transition: all 0.2s;
  pointer-events: auto !important; /* FORCER */
  position: relative;
  z-index: 10000; /* TRÈS HAUT */
}

.btn-validate:hover:not(:disabled) {
  background: linear-gradient(135deg, #45a049, #5da961);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-validate:disabled {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5);
  cursor: not-allowed;
}

.btn-cancel {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  padding: 14px 20px;
  border-radius: 8px;
  min-height: 48px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  background: rgba(255,255,255,0.15);
}

/* === DRAG & POINTER SETTINGS === */
#handFan {
  /* Par défaut, utiliser Pointer Events pour des interactions fiables (notamment mobile) */
  touch-action: none !important;
  pointer-events: auto;
}

.hand-card {
  --drag-offset-x: 0px;
  --drag-offset-y: 0px;
  --liftY: 0px;
  cursor: grab;
  pointer-events: auto;
  user-select: none;
}

/* Desktop: activer le drag natif pour confort souris */
@media (pointer: fine) {
  .hand-card { -webkit-user-drag: element; }
}

/* Mobile/tactile: désactiver le drag natif, on utilise Pointer Events */
@media (pointer: coarse) {
  .hand-card { -webkit-user-drag: none; }
  
  /* FIX: Melds full width on mobile */
  .staging-group {
    flex: 1 1 100%;
    width: 100%;
    max-width: 100%;
  }
  
  .meld {
    min-width: 100% !important;
    width: 100% !important;
    justify-content: flex-start;
    padding-left: 10px;
  }
}

.hand-card.is-dragging {
  cursor: grabbing;
  transform: 
    translateX(calc(-50% + var(--offsetX, 0px) + var(--drag-offset-x)))
    translateY(calc(var(--liftY) + var(--drag-offset-y)))
    rotate(var(--angle, 0deg))
    scale(1.05);
  transition: none;
  z-index: 1000 !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.hand-card.is-selected {
  /* Carte sélectionnée: monte de 25px (géré par JS via --liftY) */
  /* Z-index bas (géré par JS) = carte derrière les autres */
  /* Bordure verte visible + ombre */
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.6);
  outline: 3px solid #4CAF50;
  outline-offset: -1px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  /* IMPORTANT: Rester cliquable même avec z-index bas */
  pointer-events: auto !important;
}

/* ALIAS: .selected = .is-selected pour compatibilité */
.hand-card.selected,
.card.selected,
.hand-fan .card.selected {
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.6);
  outline: 3px solid #4CAF50;
  outline-offset: -1px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  pointer-events: auto !important;
}

/* Dropzone highlight */
.dropzone--active {
  outline: 3px solid #4CAF50;
  box-shadow: 0 0 0 6px rgba(76, 175, 80, 0.3);
  transition: all 150ms ease;
}

#discardTop.dropzone--active {
  transform: scale(1.1);
}

/* Mobile: même comportement que PC - lift de 25px (géré par JS) */
@media (max-width: 768px) {
  /* Ne pas overrider --liftY ici, c'est géré par JS de façon uniforme */
  
  .staging-sheet {
    max-height: 70vh;
  }
}
