/* ===== 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; }

@keyframes btn-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
.btn--loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn--loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  animation: btn-spin 0.6s linear infinite;
}
.btn-ghost.btn--loading::after {
  border-color: rgba(255,255,255,0.2);
  border-top-color: rgba(255,255,255,0.8);
}

.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;
}

/* ===== 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;
}

/* ===== AI BADGE ===== */
.ai-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.ai-badge.novice     { background: #d4edda; color: #155724; }
.ai-badge.normal     { background: #cce5ff; color: #004085; }
.ai-badge.expert     { background: #fff3cd; color: #856404; }
.ai-badge.imbattable { background: #f8d7da; color: #721c24; }

/* ===== SETUP MODE TOGGLE ===== */
.setup-mode-toggle {
  display: flex;
  background: #ede3d6;
  border-radius: var(--radius);
  padding: 3px;
  gap: 3px;
}

.setup-mode-btn {
  flex: 1;
  padding: 10px 6px;
  border-radius: calc(var(--radius) - 3px);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brown-light);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.mode-icon {
  flex-shrink: 0;
}

@media (min-width: 480px) {
  .setup-mode-btn {
    flex-direction: row;
    font-size: 0.88rem;
    padding: 10px 8px;
    gap: 6px;
  }
}

.setup-mode-btn.active {
  background: var(--white);
  color: var(--brown);
  box-shadow: 0 2px 6px rgba(61,43,31,0.12);
}

/* ===== PLAYER TYPE SECTION (draft mode) ===== */
.player-entry {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-type-section {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding-left: 40px; /* aligner avec l'input (après .player-avatar) */
}

.player-type-toggle {
  display: flex;
  background: #ede3d6;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.player-type-btn {
  padding: 5px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brown-light);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}

.player-type-btn.active {
  background: var(--white);
  color: var(--brown);
  box-shadow: 0 1px 3px rgba(61,43,31,0.1);
}

.ai-difficulty-rating {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

/* ===== BARRES DE PUISSANCE (niveau IA) ===== */
.ai-difficulty-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: rgba(61, 43, 31, 0.07);
  border-radius: 10px;
  padding: 10px 10px 6px;
}

.ai-difficulty-bar-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px 8px 4px;
  min-height: 36px;
  touch-action: manipulation;
}

.ai-bar {
  width: 14px;
  border-radius: 3px 3px 2px 2px;
  background: rgba(61, 43, 31, 0.12);
  transition: transform 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}

.ai-difficulty-bar-btn:hover .ai-bar {
  transform: scaleY(1.1);
  transform-origin: bottom;
}

.ai-difficulty-bar-btn:active .ai-bar {
  transform: scaleY(0.92);
  transform-origin: bottom;
  transition-duration: 0.05s;
}

.ai-bar-label {
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--brown-light);
  text-align: center;
  white-space: nowrap;
}

.ai-bar-label.active {
  font-weight: 800;
}

.ai-difficulty-header {
  font-size: 0.72rem;
  font-weight: 700;
  padding-left: 2px;
  transition: color 0.2s;
}

/* ===== 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;
}

/* ============================================================
   DRAFT-OPPONENTS — joueur actuel + vue agrandie adversaire
   ============================================================ */

/* Outline amber sur la mini-grille du joueur actuel */
.draft-opponent--me .mini-grid {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 3px;
}
/* Flèche directionnelle entre les joueurs du draft */
.draft-pass-arrow {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  font-size: 0.8rem;
  opacity: 0.75;
}
.draft-dir--left .draft-pass-arrow::before { content: '▶'; }
.draft-dir--right .draft-pass-arrow::before { content: '◀'; }
.draft-dir--two  .draft-pass-arrow::before { content: '▶'; }
/* Cursor pointer + hover uniquement sur les adversaires */
.draft-opponent:not(.draft-opponent--me) {
  cursor: pointer;
}
.draft-opponent:not(.draft-opponent--me):hover .mini-grid {
  outline: 2px solid rgba(255,255,255,0.35);
  outline-offset: 2px;
  border-radius: 3px;
}
.draft-opponent:not(.draft-opponent--me):active .mini-grid {
  outline-color: var(--gold);
}

/* Dialog vue adversaire agrandie */
.opponent-view-dialog {
  border: none;
  padding: 0;
  width: 100%;
  max-width: 100%;
  max-height: calc(100svh - 32px);
  box-shadow: 0 12px 40px rgba(61,43,31,0.5);
  overflow: hidden;
  background: var(--white);
}
.opponent-view-dialog::backdrop {
  background: rgba(20,10,5,0.65);
  backdrop-filter: blur(3px);
}
.opponent-view-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  max-height: calc(100svh - 32px);
  box-sizing: border-box;
}
.opponent-view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  padding-right: 36px;
}
.opponent-view-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}
.opponent-view-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(0,0,0,0.05);
}
.opponent-nav-btn {
  background: rgba(244,162,97,0.15);
  border: 2px solid var(--amber);
  color: var(--brown);
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: background 0.15s;
}
.opponent-nav-btn:hover  { background: rgba(244,162,97,0.28); }
.opponent-nav-btn:active { background: rgba(244,162,97,0.45); }
.opponent-nav-btn:disabled { opacity: 0.2; pointer-events: none; }
.opponent-close-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: none;
  color: var(--brown-light);
  font-size: 1rem;
  font-weight: 700;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
}
.opponent-close-btn:hover  { background: rgba(61,43,31,0.08); color: var(--brown); }
.opponent-close-btn:active { background: rgba(61,43,31,0.15); }
.opponent-view-indicator {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brown-light);
  letter-spacing: 0.05em;
}
.opponent-view-grid-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}
.opponent-view-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 4px;
  width: min(calc(100vw - 64px), 300px);
  aspect-ratio: 5/4;
}
.opponent-view-cell {
  border-radius: 6px;
  background: rgba(61,43,31,0.08);
  border: 1px solid rgba(61,43,31,0.15);
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
  aspect-ratio: 1;
}
.opponent-view-cell.has-card { border-color: rgba(61,43,31,0.3); }
@media (min-width: 420px) {
  .opponent-view-grid  { width: min(calc(100vw - 64px), 340px); }
}
/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
/* ===== 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-savane {
  width: 130px;
  height: 100px;
  object-fit: cover;
  object-position: left center;
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  flex-shrink: 0;
}

.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;
  margin-bottom: 20px;;
}

.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-link-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

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

.welcome-no-access {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 14px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.welcome-no-access p { margin: 0; }
.welcome-no-access .btn-ghost,
#btn-welcome-admin,
#btn-welcome-logout-main {
  border-color: rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.85);
}
.welcome-no-access .btn-ghost:hover,
#btn-welcome-admin:hover,
#btn-welcome-logout-main:hover {
  background: rgba(255,255,255,0.1);
}
/* ===== SCREEN 1 : SETUP ===== */
#screen-setup {
  background: var(--beige);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header cinématique */
.setup-header {
  position: relative;
  min-height: 180px;
  overflow: hidden;
  background-image: url('../images_web/header.png');
  background-size: cover;
  background-position: center 50%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 44px 20px 56px;
}

/* Overlay sombre (lisibilité du logo) */
.setup-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.10) 0%,
    rgba(0,0,0,0.55) 100%
  );
  z-index: 0;
}

/* Fondu vers le beige du scroll en bas */
.setup-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: linear-gradient(180deg, transparent 0%, #FAF0DC 100%);
  z-index: 1;
}

.btn-back {
  position: absolute;
  top: 16px;
  left: 20px;
  z-index: 2;
  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;
  transition: color 0.15s;
  touch-action: manipulation;
  display: block;
}
.btn-back:hover { color: #fff; }

.setup-logo {
  position: relative;
  z-index: 2;
  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;
}

/* 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: 12px;
}

/* ===== PLAYER CARD ===== */
.player-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(61,43,31,0.10);
  border: 1.5px solid rgba(61,43,31,0.10);
}

.player-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
}

.player-card-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.player-card-body {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 14px;
}

.player-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* Base .player-avatar — taille par défaut (autres écrans) */
.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(0,0,0,0.06);
  border: 2px solid transparent;
}

/* Override dans la player-card setup */
.player-card .player-avatar {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2.5px solid transparent;
}

.player-card input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  height: 40px;
  border: 2px solid #e8d8c4;
  border-radius: var(--radius);
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brown);
  background: #fdf8f2;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.player-card input:focus { background: #fff; }
.player-card input::placeholder { color: #c0a888; font-weight: 400; }

.player-card-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-card-type-row .ai-difficulty-bars {
  padding: 2px 0;
  gap: 0;
}

.player-ready {
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  opacity: 0;
  transition: opacity 0.25s;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.92);
}
.player-ready.visible { opacity: 1; }

.player-card-header .btn-remove-player {
  background: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.75);
  border: none;
  border-radius: 6px;
  padding: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
}
.player-card-header .btn-remove-player:hover {
  background: rgba(255,255,255,0.35);
  color: #fff;
}

/* 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;
}

/* ===== AVATAR STYLE PICKER ===== */
.avatar-style-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(61,43,31,0.08);
}

.avatar-style-subtitle {
  font-size: 0.72rem;
  color: var(--brown-light);
  opacity: 0.65;
  line-height: 1.4;
  margin: 0;
}

.avatar-style-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  overflow-y: auto;
  max-height: 160px;
  padding: 4px;
}

.avatar-style-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(61,43,31,0.04);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 8px 4px 7px;
  margin: 2px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s, box-shadow 0.15s;
  touch-action: manipulation;
}
.avatar-style-btn img {
  display: block;
  border-radius: 6px;
  width: 36px;
  height: 36px;
}
.avatar-style-name {
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--brown-light);
  text-align: center;
  line-height: 1.2;
}
.avatar-style-btn:hover {
  border-color: var(--amber);
  background: rgba(244,162,97,0.1);
}
.avatar-style-btn.active {
  border-color: var(--amber);
  background: rgba(244,162,97,0.18);
  transform: scale(1.1);
  box-shadow: 0 0 0 3px rgba(244,162,97,0.35);
}
.avatar-style-btn.active .avatar-style-name {
  color: var(--brown);
  font-weight: 800;
}
/* ===== 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;
}
.header-player-avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(255,255,255,0.12);
}
.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;
  position: relative;
}

/* ===== 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;
}

.placement-mode-hint {
  margin: 4px 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  line-height: 1.35;
  text-align: center;
}

.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;
}

/* ===== 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);
  }
}

/* ===== 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);
  }
}

/* ===== GRAND ÉCRAN : PALETTE LATÉRALE ===== */
@media (min-width: 820px) {

  /* 1. Layout 2D : header pleine largeur, grille + palette côte à côte */
  .placement-layout {
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "header  header"
      "grid    palette";
  }
  .placement-header { grid-area: header; }
  .grid-wrapper     { grid-area: grid; }
  .palette-wrapper  { grid-area: palette; }

  /* 2. Palette : colonne fixe 180px, flex column pour distribuer l'espace */
  .palette-wrapper {
    width: 180px;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
  }

  /* 3. Mode toggle : ne se comprime pas */
  .mode-toggle-bar {
    flex-shrink: 0;
  }

  /* 4. Grille palette : 2 colonnes × 6 lignes, remplit toute la hauteur */
  .card-palette {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(6, 1fr);
    flex: 1;
    gap: 4px;
    min-height: 0;
  }

  /* 5. Items : annule le height: 72px fixe imposé par >=540px */
  .palette-item {
    height: auto;
    min-height: 0;
  }

  /* 6. Grille de jeu : contrainte par hauteur seule (palette n'est plus en bas) */
  .grid-5x4 {
    max-width: min(
      calc(100vw - 196px),
      max(200px, calc((100vh - 56px) * 5 / 4))
    );
  }
}
/* ===== 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;
}
.score-players-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
}
.score-player-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  max-width: 50%;
  padding: 10px 10px;
  border-radius: var(--radius);
  border: 2px solid #e0d5c8;
  background: var(--white);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--brown);
  cursor: pointer;
}
.score-player-chip.done {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #166534;
  cursor: default;
}
.score-player-chip.current {
  border-color: var(--amber);
  background: rgba(244,162,97,0.12);
  cursor: default;
}
.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.chip-status { font-size: 0.8rem; opacity: 0.8; flex-shrink: 0; }
/* ===== 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-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(0,0,0,0.05);
}
.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);
}
/* ===== SCREEN DRAFT ===== */
#screen-draft {
  background: var(--beige);
}

.draft-layout {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  height: 100%;
  overflow: hidden;
}

#draft-disconnection-zone:empty {
  display: none;
}

.draft-header {
  background: var(--brown);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.draft-progress {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--gold);
  flex-shrink: 0;
}

.draft-pass-info {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  flex-shrink: 0;
}

.draft-opponents {
  background: var(--brown);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 8px 14px;
  display: flex;
  gap: 18px;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.draft-opponent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.draft-opponent-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  width: 80px;
  max-width: 80px;
}

.draft-opponent-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: contain;
  background: rgba(255,255,255,0.1);
  border: 1.5px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.draft-opponent-name {
  font-size: 1rem;
  color: var(--beige);
  font-weight: 700;
  width: 80px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  position: relative;
}

.draft-opponent-avatar[data-difficulty="novice"]     { border-color: #28a745; }
.draft-opponent-avatar[data-difficulty="normal"]     { border-color: #4d9ef5; }
.draft-opponent-avatar[data-difficulty="expert"]     { border-color: #ffc107; }
.draft-opponent-avatar[data-difficulty="imbattable"] { border-color: #e74c3c; }

/* ===== TOGGLE COLLAPSE ADVERSAIRES ===== */
.draft-opponents-toggle {
  flex-shrink: 0;
  align-self: center;
  margin-left: auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.55);
  font-size: 0.55rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.draft-opponents-toggle::before { content: '▲'; }
.draft-opponents.collapsed .draft-opponents-toggle::before { content: '▼'; }

/* État replié : bande fine, avatars seuls */
.draft-opponents.collapsed {
  padding-top: 5px;
  padding-bottom: 5px;
  gap: 10px;
  align-items: center;
}
.draft-opponents.collapsed .mini-grid,
.draft-opponents.collapsed .draft-opponent-name,
.draft-opponents.collapsed .draft-pass-arrow { display: none; }
.draft-opponents.collapsed .draft-opponent-header { width: auto; }
.draft-opponents.collapsed .draft-opponent-avatar {
  width: 22px;
  height: 22px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  width: 80px;
}

.mini-cell {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.08);
  background-size: cover;
  background-position: center 20%;
}

.mini-cell.has-card {
  border-color: rgba(255,255,255,0.25);
}

.draft-hand {
  background: var(--brown);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 6px;
  align-items: end;
}

.draft-hand-card {
  width: 100%;
  height: auto;
  aspect-ratio: 7/9;
  position: relative;
  border-radius: 8px;
  background-size: cover;
  background-position: center 20%;
  background-repeat: no-repeat;
  background-color: rgba(255,255,255,0.1);
  border: 3px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}

.draft-hand-card:active { transform: scale(0.9); }

.draft-hand-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), 0 6px 14px rgba(0,0,0,0.35);
  transform: translateY(-6px);
}

.draft-hand-card-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  text-align: center;
  padding: 10px 2px 3px;
  border-radius: 0 0 5px 5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  line-height: 1.1;
}

/* Cellule de grille disponible pour placement draft */
.grid-cell.draft-available {
  border: 2px dashed var(--teal);
  background: rgba(42,157,143,0.1);
  cursor: pointer;
}
.grid-cell.draft-available:hover {
  background: rgba(42,157,143,0.22);
}

/* ===== GRAND ÉCRAN : LAYOUT 3 COLONNES ===== */
@media (min-width: 820px) {
  .draft-layout {
    grid-template-rows: auto 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-columns: 100px 1fr 220px;
    grid-template-areas:
      "header    header  header"
      "zone      zone    zone"
      "opponents grid    hand";
  }
  .draft-header              { grid-area: header; }
  #draft-disconnection-zone  { grid-area: zone; }
  .draft-opponents           { grid-area: opponents; }
  .grid-wrapper              { grid-area: grid; }
  .draft-hand                { grid-area: hand; }

  /* Opponents : colonne verticale compacte */
  .draft-opponents {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 7px;
    gap: 6px;
    border-top: none;
    border-right: 1px solid rgba(255,255,255,0.08);
  }
  .draft-opponent {
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
  }
  .draft-opponent-name {
    font-size: 0.85rem;
    width: 100%;
    max-width: 100%;
  }
  .draft-dir--left  .draft-pass-arrow::before { content: '▼'; }
  .draft-dir--right .draft-pass-arrow::before { content: '▲'; }
  .draft-dir--two   .draft-pass-arrow::before { content: '▼'; }
  .mini-grid {
    width: 100%;
  }
  .mini-cell {
    width: auto;
    height: auto;
    aspect-ratio: 1;
  }

  /* Hand : sidebar droite élargie */
  .draft-hand {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    min-height: 0;
    align-items: center;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,0.08);
  }
  .draft-hand-card {
    flex-shrink: 0;
    width: 50%;
    height: auto;
    aspect-ratio: 7/9;
  }

  /* Grille de jeu : contrainte par hauteur + soustraire les 2 colonnes */
  .draft-layout .grid-5x4 {
    max-width: min(
      calc(100vw - 100px - 220px - 20px),
      max(200px, calc((100vh - 56px) * 5 / 4))
    );
  }
}

/* ===== PETITS ÉCRANS (hauteur < 810px, layout mobile) : draft-hand 2 lignes max ===== */
@media (max-height: 790px) and (max-width: 819px) {
  .draft-hand {
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    grid-template-rows: repeat(2, auto);
    grid-auto-rows: 0;
    overflow: hidden;
    align-items: start;
  }
}
/* ============================================================
   ÉCRAN LOBBY
   ============================================================ */
.lobby-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--brown);
}

.lobby-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--beige);
  flex: 1;
  text-align: center;
}

.lobby-code-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 20px 16px;
}

.lobby-code-label {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  margin: 0;
}

.lobby-code-big {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--amber);
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 10px 24px;
  min-width: 220px;
  text-align: center;
}

.lobby-players {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.lobby-player-icon {
  font-size: 1.3rem;
  min-width: 28px;
  text-align: center;
}

.lobby-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  vertical-align: middle;
}

.lobby-player-name {
  flex: 1;
  color: var(--beige);
  font-weight: 600;
}

.lobby-player-status {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
}

.lobby-player-status.joined {
  color: #4ade80;
}

.lobby-footer {
  padding: 16px;
  background: var(--brown);
  border-top: 1px solid rgba(255,255,255,0.1);
}

/* ============================================================
   ÉCRAN JOIN
   ============================================================ */
.join-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px;
  gap: 24px;
  height: 100%;
  background: var(--brown);
}

.join-layout h2 {
  color: var(--beige);
  font-size: 1.5rem;
  margin: 0;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 360px;
}

.join-form input {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  color: var(--beige);
  font-size: 1rem;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.2s;
}

#join-name-input {
  text-transform: none;
  letter-spacing: normal;
}

.join-form input:focus {
  border-color: var(--amber);
}

.join-form input::placeholder {
  color: rgba(255,255,255,0.35);
  text-transform: none;
  letter-spacing: normal;
}

/* ============================================================
   OVERLAY "En attente" sur la grille draft (mode online)
   ============================================================ */
.draft-pending-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  z-index: 10;
  pointer-events: all;
}

.draft-pending-overlay-text {
  color: var(--beige);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  padding: 16px;
}

/* ============================================================
   TOAST ONLINE (connexion perdue, etc.)
   ============================================================ */
.online-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30,20,10,0.92);
  color: var(--beige);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--amber);
  z-index: 9999;
  white-space: nowrap;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   SETUP — Mode online-draft
   ============================================================ */
.setup-mode-btn[data-mode="online-draft"].active {
  background: var(--amber);
  color: var(--brown);
}

.player-type-btn[data-type="remote"].active {
  background: #3b82f6;
  color: #fff;
}

.player-slot-host-badge {
  font-size: 0.7rem;
  background: var(--amber);
  color: var(--brown);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
  margin-left: 4px;
}

/* ============================================================
   BANNERIÈRE DÉCONNEXION (mode online-draft)
   ============================================================ */
.online-disconnection-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(160, 45, 20, 0.95);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-bottom: 2px solid rgba(255,120,60,0.5);
  border-top: 2px solid rgba(255,120,60,0.5);
  animation: banner-in 0.25s ease;
}

.online-disconnection-banner .banner-message {
  flex: 1;
  min-width: 0;
}

.online-disconnection-banner .banner-quit-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.15s;
}

.online-disconnection-banner .banner-quit-btn:hover  { background: rgba(255,255,255,0.25); }
.online-disconnection-banner .banner-quit-btn:active { background: rgba(255,255,255,0.35); }

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   HINT CONTEXTUEL SOUS LE TOGGLE DE MODE
   ============================================================ */
.setup-mode-hint {
  margin: 8px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--brown);
  font-size: 0.82rem;
  line-height: 1.45;
}

.setup-mode-hint strong {
  color: #b45309;
}

/* Bouton quitter la partie online */
.btn-draft-quit {
  color: rgba(255, 180, 150, 0.85);
}
.btn-draft-quit:hover,
.btn-draft-quit:active {
  color: #fff;
  background: rgba(200, 60, 30, 0.5);
}
/* ===== SCREEN LOGIN ===== */
#screen-login {
  background: linear-gradient(170deg, #1e3a0e 0%, #2D5016 45%, #3a6b1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  text-align: center;
}

.login-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--brown, #3D2B1F);
  margin: 0;
  line-height: 1.3;
}

.login-subtitle {
  font-size: 0.95rem;
  font-weight: 600;
  color: #888;
  margin: 0;
}

.login-input-wrap {
  position: relative;
  width: 100%;
}

.login-input {
  width: 100%;
  padding: 14px 44px 14px 16px;
  border-radius: 12px;
  border: 2px solid #e0d8d0;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.login-eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #aaa;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.login-eye:hover { color: #555; }

.login-input:focus {
  outline: none;
  border-color: var(--terracotta, #E76F51);
}

.login-btn {
  margin-top: 4px;
}

.login-error {
  color: #DC2626;
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}
