/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --amber:     #F4A261;
  --terracotta:#E76F51;
  --gold:      #E9C46A;
  --teal:      #2A9D8F;
  --beige:     #F5E6C8;
  --brown:     #3D2B1F;
  --brown-light: #6B4A2A;
  --white:     #FFFDF7;
  --shadow:    rgba(61,43,31,0.18);
  --radius:    12px;
  --radius-lg: 20px;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--beige);
  font-family: 'Nunito', sans-serif;
  color: var(--brown);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background: var(--beige);
  will-change: transform;
}
.screen.active {
  transform: translateX(0);
}
.screen.slide-out {
  transform: translateX(-40%);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, opacity 0.1s, background 0.15s;
  min-height: 44px;
  padding: 0 20px;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--terracotta);
  color: #fff;
  box-shadow: 0 3px 10px rgba(231,111,81,0.4);
}
.btn-primary:hover { background: #d4634a; }

.btn-secondary {
  background: var(--amber);
  color: var(--brown);
  box-shadow: 0 2px 8px rgba(244,162,97,0.3);
}
.btn-secondary:hover { background: #e8924d; }

.btn-ghost {
  background: transparent;
  color: var(--brown-light);
  border: 2px solid var(--amber);
}
.btn-ghost:hover { background: rgba(244,162,97,0.1); }

.btn-sm { font-size: 0.85rem; min-height: 36px; padding: 0 12px; }
.btn-large { width: 100%; font-size: 1.1rem; min-height: 52px; border-radius: var(--radius-lg); }

/* ===== CARD BADGE ===== */
.player-name-badge {
  background: var(--gold);
  color: var(--brown);
  font-weight: 800;
  font-size: 1rem;
  border-radius: 999px;
  padding: 4px 14px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ===== SCREEN 0 : WELCOME ===== */
#screen-welcome {
  background: linear-gradient(170deg, #1e3a0e 0%, #2D5016 45%, #3a6b1a 100%);
  overflow-y: auto;
}

.welcome-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 40px 24px 40px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
  min-height: 100%;
}

.welcome-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding-top: 8px;
}

.welcome-lion {
  width: 88px;
  height: 88px;
  object-fit: contain;
  filter: drop-shadow(0 6px 20px rgba(0,0,0,0.45));
  flex-shrink: 0;
}

.welcome-title {
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.1;
}
.welcome-title span { color: var(--gold); }

.welcome-tagline {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.6);
  margin-top: 5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.welcome-desc {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  color: rgba(255,255,255,0.85);
  font-size: 0.95rem;
  line-height: 1.65;
}

.welcome-features {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255,255,255,0.07);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: rgba(255,255,255,0.9);
}

.welcome-feature-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  line-height: 1.3;
}

.welcome-feature strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 2px;
}

.welcome-feature span {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.4;
}

/* PWA Install Banner */
.pwa-install-banner {
  background: rgba(244,162,97,0.15);
  border: 2px solid rgba(244,162,97,0.6);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pwa-banner-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.pwa-banner-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}

.pwa-banner-top strong {
  display: block;
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 4px;
}

.pwa-banner-top p {
  color: rgba(255,255,255,0.75);
  font-size: 0.83rem;
  line-height: 1.5;
}

.btn-pwa {
  background: var(--amber);
  color: var(--brown);
  width: 100%;
  font-size: 1rem;
  min-height: 44px;
  border-radius: var(--radius);
  box-shadow: 0 3px 10px rgba(244,162,97,0.3);
}
.btn-pwa:hover { background: #e8924d; }

/* Footer */
.welcome-footer {
  margin-top: auto;
  padding-top: 8px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link {
  color: rgba(255,255,255,0.45);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: color 0.15s;
}
.footer-link:hover { color: rgba(255,255,255,0.8); }

.footer-sep {
  color: rgba(255,255,255,0.25);
  font-size: 0.82rem;
}

/* ===== SCREEN 1 : SETUP ===== */
#screen-setup {
  background: var(--beige);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header vert savane */
.setup-header {
  background: linear-gradient(160deg, #1e3a0e 0%, #2D5016 55%, #3a6b1a 100%);
  padding: 16px 20px 20px;
  flex-shrink: 0;
}

.btn-back {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  padding: 4px 0;
  margin-bottom: 14px;
  transition: color 0.15s;
  touch-action: manipulation;
  display: block;
}
.btn-back:hover { color: #fff; }

.setup-logo {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
  flex-shrink: 0;
}
.logo-title {
  font-size: 1.9rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
}
.logo-title span { color: var(--gold); }
.logo-subtitle {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.02em;
}

/* Bande décorative de cartes */
.setup-deco-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.setup-deco-card {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0,0,0,0.35));
  opacity: 0.75;
}

/* Zone scrollable */
.setup-scroll {
  flex: 1;
  overflow-y: auto;
  background: linear-gradient(180deg, #F0E0BB 0%, #FAF0DC 40%);
}
.setup-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 20px 20px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* Carte joueurs */
.setup-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 6px 24px rgba(61,43,31,0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--brown-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--amber);
  color: var(--brown);
  font-size: 0.85rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(244,162,97,0.4);
}
.player-row input[type="text"] {
  flex: 1;
  height: 48px;
  border: 2px solid #e8d8c4;
  border-radius: var(--radius);
  padding: 0 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brown);
  background: #fdf8f2;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.player-row input:focus { border-color: var(--amber); background: #fff; }
.player-row input::placeholder { color: #c0a888; font-weight: 400; }

.btn-remove-player {
  background: none;
  border: none;
  color: #c8b0a0;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  min-height: 44px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.btn-remove-player:hover { color: var(--terracotta); background: #fde8e3; }

/* Footer fixé en bas */
.setup-footer {
  flex-shrink: 0;
  padding: 10px 20px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(61,43,31,0.1);
  background: #F0E0BB;
}
.setup-footer-link {
  color: var(--brown-light);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.setup-footer-link:hover { opacity: 1; }
.setup-footer-sep {
  color: var(--brown-light);
  font-size: 0.78rem;
  opacity: 0.3;
}
.setup-footer-version {
  color: var(--brown-light);
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
}

/* ===== SCREEN 2 : PLACEMENT ===== */
#screen-placement {
  background: var(--beige);
}
.placement-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  overflow: hidden;
}

.placement-header {
  background: var(--brown);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.card-counter {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--gold);
  flex-shrink: 0;
}

.btn-player-nav {
  background: rgba(255,255,255,0.12);
  border: none;
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.15s, opacity 0.15s;
}
.btn-player-nav:active { background: rgba(255,255,255,0.22); }
.btn-player-nav:disabled { opacity: 0.2; pointer-events: none; }

.grid-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: hidden;
  min-height: 0;
}

/* ===== GRILLE 5×4 ===== */
.grid-5x4 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  width: 100%;
  max-width: min(95vw, max(200px, calc((100vh - 300px) * 5 / 4)));
  aspect-ratio: 5/4;
}

.grid-cell {
  border-radius: 8px;
  background: rgba(255,255,255,0.5);
  border: 2px dashed #c8b89a;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  touch-action: manipulation;
  overflow: hidden;
  aspect-ratio: 1;
}
.grid-cell:active { transform: scale(0.94); }

.grid-cell.has-card {
  border: 2px solid #d4c4aa;
  cursor: default;
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
}
.grid-cell.face-down {
  border-color: var(--brown-light);
  filter: grayscale(1) brightness(0.35);
}

.cell-remove-btn {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--terracotta);
  color: #fff;
  border: none;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  padding: 0;
}
.grid-cell.has-card:hover .cell-remove-btn,
.grid-cell.has-card:focus-within .cell-remove-btn {
  display: flex;
}

/* Highlight pour sélection */
.grid-cell.selected-target {
  background: rgba(42,157,143,0.15);
  border: 2px dashed var(--teal);
}

/* ===== PALETTE ===== */
.palette-wrapper {
  background: var(--brown);
  padding: 6px 8px;
  overflow: hidden;
}

.card-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  width: 100%;
}

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  touch-action: manipulation;
  padding: 6px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
  width: 100%;
}
.palette-item:active { transform: scale(0.92); }
.palette-item.selected {
  background: rgba(233,196,106,0.25);
  border-color: var(--gold);
}

.palette-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
  border-radius: 6px;
  pointer-events: none;
}
.palette-item .palette-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--beige);
  text-align: center;
  line-height: 1.1;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.palette-item .palette-count {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--gold);
}

/* Bouton reset dans le header */
.btn-player-nav.btn-reset {
  color: #e07060;
  margin-left: 2px;
}
.btn-player-nav.btn-reset:active { background: rgba(224,112,96,0.18); }

/* Bouton Valider intégré dans la palette */
.palette-item-validate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  border-radius: 10px;
  border: 2px solid var(--teal);
  background: rgba(42,157,143,0.18);
  color: var(--teal);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.7rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
  text-align: center;
  line-height: 1.2;
}
.palette-item-validate:active { transform: scale(0.92); }
.palette-item-validate:disabled {
  opacity: 0.35;
  pointer-events: none;
  border-color: #888;
  color: #888;
  background: transparent;
}
.palette-item-validate .validate-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ===== SCREEN 3 : LION MODAL ===== */
#screen-lion {
  background: transparent;
  pointer-events: none;
  transform: none !important;
}
#screen-lion.active { pointer-events: auto; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(61,43,31,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}
#screen-lion.active .modal-backdrop { opacity: 1; }

.modal-panel {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 14px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
#screen-lion.active .modal-panel { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.modal-icon { width: 48px; height: 48px; object-fit: contain; }
.modal-title { font-size: 1.25rem; font-weight: 900; color: var(--brown); }
.modal-subtitle { font-size: 0.9rem; font-weight: 600; color: var(--brown-light); margin-top: 2px; }

.modal-grid-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.modal-grid-wrapper .grid-5x4 {
  max-width: min(90vw, 380px);
}

.modal-footer {
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Lion grid specials */
.grid-cell.lion-active {
  border: 3px solid var(--gold);
  background: rgba(233,196,106,0.2);
  box-shadow: 0 0 0 2px var(--gold);
}
.grid-cell.lion-target {
  border: 3px solid var(--teal);
  cursor: pointer;
}
.grid-cell.lion-target img {
  animation: pulse-teal 1.2s ease-in-out infinite;
}
@keyframes pulse-teal {
  0%, 100% { filter: drop-shadow(0 0 4px var(--teal)); }
  50%       { filter: drop-shadow(0 0 10px var(--teal)); }
}
.grid-cell.lion-dim {
  opacity: 0.35;
  pointer-events: none;
}

/* ===== SCREEN 4 : SCORE ===== */
#screen-score { background: var(--beige); }
.score-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.score-header {
  background: var(--brown);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.score-player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}
.score-total-badge {
  margin-left: auto;
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold);
}

.score-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.score-row {
  background: var(--white);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 8px var(--shadow);
}
.score-row img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.score-row-info { flex: 1; min-width: 0; }
.score-row-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--brown);
}
.score-row-detail {
  font-size: 0.8rem;
  color: var(--brown-light);
  font-weight: 600;
  margin-top: 1px;
}
.score-row-pts {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--terracotta);
  min-width: 44px;
  text-align: right;
}
.score-row-pts.pending {
  color: var(--amber);
  font-size: 0.95rem;
}
.score-row-pts.negative { color: #c0392b; }

.score-footer {
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--beige);
  border-top: 2px solid #e0d5c8;
}

/* ===== SCREEN 5 : RANKING ===== */
#screen-ranking { background: linear-gradient(160deg, #F5E6C8 0%, #FAEBD0 60%, #F5E6C8 100%); }
.ranking-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.ranking-header {
  padding: 20px 20px 10px;
  text-align: center;
}
.ranking-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--brown);
}

.ranking-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
}
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

.ranking-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px var(--shadow);
  overflow: hidden;
  cursor: pointer;
}
.ranking-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  user-select: none;
}
.ranking-rank {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--amber);
  min-width: 32px;
}
.ranking-rank.rank-1 { color: #FFD700; }
.ranking-rank.rank-2 { color: #B0B0B0; }
.ranking-rank.rank-3 { color: #CD7F32; }

.ranking-name {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--brown);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking-score {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--terracotta);
}
.ranking-chevron {
  font-size: 1rem;
  color: var(--amber);
  transition: transform 0.25s;
  margin-left: 4px;
}
.ranking-card.open .ranking-chevron { transform: rotate(90deg); }

.ranking-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4,0,0.2,1);
  background: #fdf8f0;
  border-top: 0px solid #e0d5c8;
}
.ranking-card.open .ranking-detail {
  max-height: 800px;
  border-top-width: 1px;
}
.ranking-detail-inner {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ranking-detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}
.ranking-detail-row img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.ranking-detail-row-name {
  flex: 1;
  font-weight: 700;
  color: var(--brown);
}
.ranking-detail-row-pts {
  font-weight: 800;
  color: var(--terracotta);
  min-width: 40px;
  text-align: right;
}
.ranking-detail-row-pts.negative { color: #c0392b; }

.ranking-footer {
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

/* ===== TABLEAU RÉCAP ===== */
.ranking-recap {
  max-width: 640px;
  margin: 20px auto 0;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px var(--shadow);
  overflow: hidden;
}
.ranking-recap h3 {
  font-size: 1rem;
  font-weight: 900;
  color: var(--brown);
  padding: 12px 16px 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--beige);
}
.recap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.recap-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Nunito', sans-serif;
  white-space: nowrap;
}
.recap-table th,
.recap-table td {
  padding: 6px 10px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  border-bottom: 1px solid #ede3d6;
}
/* Première colonne : label carte */
.recap-table th:first-child,
.recap-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--white);
  z-index: 1;
  padding-left: 12px;
  min-width: 110px;
}
/* Header joueurs */
.recap-table thead th {
  background: var(--brown);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.8rem;
  border-bottom: none;
}
.recap-table thead th:first-child {
  background: var(--brown);
  color: var(--beige);
}
/* Lignes alternées */
.recap-table tbody tr:nth-child(even) td { background: #fdf8f0; }
.recap-table tbody tr:nth-child(even) td:first-child { background: #fdf8f0; }
/* Cellule carte : image + nom */
.recap-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.recap-card-label img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}
/* Score normal / négatif */
.recap-pts { color: var(--brown); }
.recap-pts.neg { color: #c0392b; }
.recap-pts.zero { color: #b5a090; }
/* Ligne total */
.recap-table tfoot td {
  background: var(--brown) !important;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 900;
  border-bottom: none;
  padding: 10px 10px;
}
.recap-table tfoot td:first-child {
  background: var(--brown) !important;
  color: var(--beige);
}

/* ===== MODE TOGGLE ===== */
.mode-toggle-bar {
  display: flex;
  gap: 6px;
  padding: 4px 0 6px;
}
.mode-btn {
  flex: 1;
  padding: 5px 0;
  border-radius: 8px;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.15);
  color: var(--beige);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mode-btn.active {
  background: rgba(233,196,106,0.25);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 600;
}

/* ===== CURSEUR SÉQUENTIEL ===== */
.grid-cell.seq-cursor {
  border: 3px solid var(--gold);
  background: rgba(233,196,106,0.22);
  animation: pulse-cursor 0.85s ease-in-out infinite alternate;
}
@keyframes pulse-cursor {
  from {
    box-shadow: inset 0 0 6px rgba(233,196,106,0.25), 0 0 0 0 rgba(233,196,106,0);
  }
  to {
    box-shadow: inset 0 0 14px rgba(233,196,106,0.5), 0 0 0 6px rgba(233,196,106,0.3);
  }
}

/* ===== POSE DE CARTE ===== */
.grid-cell.cell-flying {
  opacity: 0;
}
.grid-cell.cell-just-placed {
  animation: cell-stamp 0.32s ease-out forwards;
  position: relative;
  z-index: 5;
}
@keyframes cell-stamp {
  0% {
    transform: scale(1.12);
    box-shadow: 0 0 0 4px rgba(255,255,255,0.7), 0 0 16px rgba(233,196,106,0.65);
    filter: brightness(1.3);
  }
  100% {
    transform: scale(1);
    box-shadow: none;
    filter: brightness(1);
  }
}

/* ===== DIALOG DE CONFIRMATION ===== */
.confirm-dialog {
  border: none;
  border-radius: 0;
  padding: 0;
  max-width: 320px;
  width: calc(100% - 40px);
  box-shadow: 0 8px 32px rgba(61,43,31,0.4);
  position: fixed;
  margin: 0;
  top: 0;
  left: 0;
}
.confirm-dialog--right {
  left: auto;
  right: 0;
}
.confirm-dialog::backdrop {
  background: rgba(20,10,5,0.65);
  backdrop-filter: blur(3px);
}
.confirm-dialog-inner {
  padding: 24px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.confirm-dialog-text {
  font-size: 0.95rem;
  color: var(--brown);
  line-height: 1.65;
}
.confirm-dialog-text strong {
  color: var(--terracotta);
}
.confirm-dialog-actions {
  display: flex;
  gap: 10px;
}
.confirm-dialog-actions .btn {
  flex: 1;
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }

/* ===== RESPONSIVE AJUSTEMENTS ===== */

@media (min-width: 480px) {
  .grid-5x4 { gap: 6px; }
  .grid-cell { border-radius: 10px; }
}

@media (min-width: 540px) {
  /* Thumb plein format, label en overlay */
  .palette-item {
    position: relative;
    padding: 0;
    overflow: hidden;
    gap: 0;
    height: 72px;
  }

  .palette-item.selected {
    background: transparent;
  }

  /* Bordure de sélection via pseudo-élément (par-dessus le thumb) */
  .palette-item.selected::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--gold);
    border-radius: 10px;
    pointer-events: none;
    z-index: 3;
  }

  .palette-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: unset;
    border-radius: 0;
  }

  .palette-item .palette-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.72));
    padding: 14px 4px 5px;
    border-radius: 0;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  }
}
