/* ============================================
   ESPRIT ES-TU LÀ ? - Styles Mobile-First v3
   Layout optimisé UX
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-card-hover: #1f3460;
  --accent: #e94560;
  --accent-light: #ff6b6b;
  --text: #eee;
  --text-muted: #888;
  --human: #4ecdc4;
  --creature: #e94560;
  --effective: #4ecdc4;
  --ineffective: #e94560;
  --neutral: #555;
  --bluff: #f39c12;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  max-width: 500px;
  margin: 0 auto;
  padding: 0.75rem;
  padding-bottom: 2rem;
}

/* ============================================
   HEADER
   ============================================ */
.header {
  text-align: center;
  padding: 0.5rem 0;
  margin-bottom: 0.4rem;
}

.header .logo {
  max-width: 280px;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.5));
}

/* ============================================
   MODES DE JEU
   ============================================ */
.modes-section {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  justify-content: center;
}

.mode-btn {
  flex: 1;
  max-width: 100px;
  padding: 0.4rem 0.4rem;
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mode-btn:hover {
  background: var(--bg-card-hover);
}

.mode-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(233, 69, 96, 0.4);
}

/* ============================================
   BARRE DE CONTRÔLE
   ============================================ */
.control-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.4rem;
  background: var(--bg-card);
  border-radius: 10px;
}

.filters {
  display: flex;
  gap: 0.25rem;
}

.filter-btn {
  padding: 0.4rem 0.6rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.filter-btn:hover {
  background: rgba(255,255,255,0.1);
}

.filter-btn.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

.filter-btn[data-filter="human"].active {
  background: rgba(78, 205, 196, 0.3);
  color: var(--human);
}

.filter-btn[data-filter="creature"].active {
  background: rgba(233, 69, 96, 0.3);
  color: var(--creature);
}

.actions {
  display: flex;
  gap: 0.25rem;
}

.action-btn {
  padding: 0.4rem 0.5rem;
  background: transparent;
  border: 1px solid var(--neutral);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--text-muted);
}

.reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================
   SECTION ATTAQUES
   ============================================ */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 0.5rem;
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot.neutral { background: var(--neutral); }
.dot.effective { background: var(--effective); }
.dot.ineffective { background: var(--ineffective); }

.attacks-section {
  margin-bottom: 0.5rem;
}

.attacks-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.attacks-row {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.attack-wrapper {
  position: relative;
}

.attack-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  background: var(--bg-card);
  border: 3px solid var(--neutral);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.attack-btn:hover {
  background: var(--bg-card-hover);
}

.attack-btn:active {
  transform: scale(0.95);
}

/* États des attaques */
.attack-btn[data-state="null"] {
  border-color: var(--neutral);
}

.attack-btn[data-state="true"] {
  border-color: var(--effective);
  background: rgba(78, 205, 196, 0.15);
  box-shadow: 0 0 12px rgba(78, 205, 196, 0.3);
}

.attack-btn[data-state="false"] {
  border-color: var(--ineffective);
  background: rgba(233, 69, 96, 0.15);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.3);
}

.attack-btn .attack-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: brightness(0.9);
  transition: filter 0.15s ease;
}

.attack-btn[data-state="true"] .attack-icon {
  filter: brightness(1.2) drop-shadow(0 0 4px var(--effective));
}

.attack-btn[data-state="false"] .attack-icon {
  filter: brightness(0.5) grayscale(0.5);
}

.attack-btn .name {
  font-size: 0.5rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  text-align: center;
  line-height: 1.1;
}

.attack-btn[data-state="true"] .name { color: var(--effective); }
.attack-btn[data-state="false"] .name { color: var(--ineffective); }

/* Indicateur d'état */
.state-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.attack-btn[data-state="null"] .state-indicator {
  background: var(--neutral);
}

.attack-btn[data-state="true"] .state-indicator {
  background: var(--effective);
}

.attack-btn[data-state="true"] .state-indicator::after {
  content: '✓';
  color: #000;
}

.attack-btn[data-state="false"] .state-indicator {
  background: var(--ineffective);
}

.attack-btn[data-state="false"] .state-indicator::after {
  content: '✗';
  color: white;
}

/* Bouton Bluff spécial */
.attack-btn.bluff-btn {
  background: linear-gradient(135deg, #2a2a4a 0%, #1a1a2e 100%);
  border-color: #8b5cf6;
  border-style: dashed;
}

.attack-btn.bluff-btn .bluff-emoji {
  font-size: 1.4rem;
}

.attack-btn.bluff-btn .name {
  color: #a78bfa;
  font-weight: 600;
}

.attack-btn.bluff-btn[data-state="false"] {
  border-color: #6b6b8d;
  opacity: 0.7;
}

.attack-btn.bluff-btn[data-state="false"] .bluff-emoji {
  filter: grayscale(0.5);
}

.attack-btn.bluff-btn[data-state="false"] .name {
  color: var(--text-muted);
}

.attack-btn.bluff-btn[data-state="false"] .state-indicator {
  background: #6b6b8d;
}

.attack-btn.bluff-btn[data-state="true"] {
  border-color: #f59e0b;
  border-style: solid;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
  animation: bluff-pulse 1.5s ease-in-out infinite;
}

.attack-btn.bluff-btn[data-state="true"] .bluff-emoji {
  animation: bluff-shake 0.5s ease-in-out infinite;
}

.attack-btn.bluff-btn[data-state="true"] .name {
  color: #f59e0b;
}

.attack-btn.bluff-btn[data-state="true"] .state-indicator {
  background: #f59e0b;
}

.attack-btn.bluff-btn[data-state="true"] .state-indicator::after {
  content: '?';
  color: #000;
  font-weight: bold;
}

@keyframes bluff-pulse {
  0%, 100% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 25px rgba(245, 158, 11, 0.6); }
}

@keyframes bluff-shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* ============================================
   SECTION CARTES ULTIMES
   ============================================ */
.ultimates-cards-section {
  margin-bottom: 0.5rem;
}

.ultimates-cards-section .section-title {
  color: var(--accent);
}

.ultimates-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

/* Boutons Cartes Ultimes */
.ultimate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  background: linear-gradient(135deg, #2a1a3e 0%, #1a1a2e 100%);
  border: 3px solid #8b5cf6;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.ultimate-btn:hover {
  background: linear-gradient(135deg, #3a2a4e 0%, #2a2a3e 100%);
}

.ultimate-btn:active {
  transform: scale(0.95);
}

.ultimate-btn .ultimate-emoji {
  font-size: 1.4rem;
}

.ultimate-btn .name {
  font-size: 0.5rem;
  color: #a78bfa;
  margin-top: 0.15rem;
  text-align: center;
  line-height: 1.1;
}

.ultimate-btn .state-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 0.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

/* États des cartes ultimes */
.ultimate-btn[data-state="null"] {
  border-color: #8b5cf6;
}

.ultimate-btn[data-state="null"] .state-indicator {
  background: #8b5cf6;
}

.ultimate-btn[data-state="true"] {
  border-color: var(--effective);
  background: linear-gradient(135deg, rgba(78, 205, 196, 0.2) 0%, rgba(78, 205, 196, 0.1) 100%);
  box-shadow: 0 0 12px rgba(78, 205, 196, 0.3);
}

.ultimate-btn[data-state="true"] .ultimate-emoji {
  filter: drop-shadow(0 0 4px var(--effective));
}

.ultimate-btn[data-state="true"] .name {
  color: var(--effective);
}

.ultimate-btn[data-state="true"] .state-indicator {
  background: var(--effective);
}

.ultimate-btn[data-state="true"] .state-indicator::after {
  content: '✓';
  color: #000;
}

.ultimate-btn[data-state="false"] {
  border-color: var(--ineffective);
  background: linear-gradient(135deg, rgba(233, 69, 96, 0.2) 0%, rgba(233, 69, 96, 0.1) 100%);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.3);
}

.ultimate-btn[data-state="false"] .ultimate-emoji {
  filter: grayscale(0.5) brightness(0.7);
}

.ultimate-btn[data-state="false"] .name {
  color: var(--ineffective);
}

.ultimate-btn[data-state="false"] .state-indicator {
  background: var(--ineffective);
}

.ultimate-btn[data-state="false"] .state-indicator::after {
  content: '✗';
  color: white;
}

/* ============================================
   RÉSULTATS HEADER
   ============================================ */
.results-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.results-header .divider {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neutral), transparent);
}

.results-header .count {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.results-header .count span {
  color: var(--effective);
  font-weight: bold;
  font-size: 1.1rem;
}

/* ============================================
   TABLEAU PERSONNAGES
   ============================================ */
.characters-section {
  margin-bottom: 0.5rem;
}

.characters-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.characters-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.characters-table thead {
  background: var(--bg-card);
  position: sticky;
  top: 0;
}

.characters-table th {
  padding: 0.3rem 0.15rem;
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.6rem;
  border-bottom: 1px solid var(--neutral);
}

.characters-table th:first-child,
.characters-table th:nth-child(3),
.characters-table th:nth-child(4),
.characters-table th:last-child {
  text-align: center;
}

.char-row {
  cursor: pointer;
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}

.char-row:hover {
  background: var(--bg-card-hover);
}

.char-row.human {
  border-left-color: var(--human);
}

.char-row.creature {
  border-left-color: var(--creature);
}

.char-row.eliminated {
  opacity: 0.15;
  pointer-events: none;
}

.char-row.hidden {
  display: none;
}

.char-row td {
  padding: 0.25rem 0.15rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  vertical-align: middle;
}

.col-avatar {
  font-size: 1rem;
  text-align: center;
  width: 1.5rem;
}

.col-name {
  font-weight: 500;
  white-space: nowrap;
}

.char-row.human .col-name {
  color: var(--human);
}

.char-row.creature .col-name {
  color: var(--creature);
}

.col-cards,
.col-hp {
  text-align: center;
  color: var(--text-muted);
  width: 1.5rem;
}

.col-weak {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.weak-icon {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

.col-ultimate {
  text-align: center;
  font-size: 0.8rem;
  width: 1.5rem;
}

/* ============================================
   FAIBLESSES ULTIMES
   ============================================ */
.ultimates-section {
  padding: 0.4rem;
  margin-top: 1rem;
  background: rgba(233, 69, 96, 0.08);
  border-radius: 10px;
  border: 1px solid rgba(233, 69, 96, 0.2);
}

.ultimates-section .section-title {
  color: var(--accent);
}

.ultimates-panel {
  margin-top: 0.5rem;
  overflow-x: auto;
}

/* Tableau Faiblesses Ultimes */
.ultimates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.ultimates-table thead {
  background: rgba(233, 69, 96, 0.15);
}

.ultimates-table th {
  padding: 0.4rem 0.3rem;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.65rem;
}

.ultimates-table th:first-child {
  width: 28px;
  text-align: center;
}

.ultimate-row {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.15s ease;
}

.ultimate-row:hover {
  background: rgba(233, 69, 96, 0.1);
}

.ultimate-row td {
  padding: 0.4rem 0.3rem;
  vertical-align: middle;
}

.ultimate-row .col-emoji {
  font-size: 1rem;
  text-align: center;
}

.ultimate-row .col-ultimate-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.ultimate-row .col-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.char-name {
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  white-space: nowrap;
}

.char-name.human {
  background: rgba(78, 205, 196, 0.2);
  color: var(--human);
  border-left: 2px solid var(--human);
}

.char-name.creature {
  background: rgba(233, 69, 96, 0.2);
  color: var(--creature);
  border-left: 2px solid var(--creature);
}

.no-results {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 0.5rem;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 100;
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 300px;
  width: 100%;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal.active .modal-content {
  transform: scale(1);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  text-align: center;
}

.modal-body .avatar {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-body h3 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.modal-body .type-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  margin-bottom: 0.5rem;
}

.modal-body .type-badge.human {
  background: var(--human);
  color: #000;
}

.modal-body .type-badge.creature {
  background: var(--creature);
  color: white;
}

.modal-body .char-stats {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.modal-body .stat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-body .section-title {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin: 0.75rem 0 0.3rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.modal-body .weaknesses {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.modal-body .weakness-tag {
  background: rgba(78, 205, 196, 0.2);
  border: 1px solid var(--effective);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.7rem;
}

.modal-body .ultimate {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.85rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 400px) {
  .characters-table {
    font-size: 0.75rem;
  }

  .weak-icon {
    width: 16px;
    height: 16px;
  }
}

@media (min-width: 500px) {
  .attack-btn {
    width: 4rem;
    height: 4rem;
  }

  .attack-btn .attack-icon {
    width: 28px;
    height: 28px;
  }

  .characters-table {
    font-size: 0.8rem;
  }
}

