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

:root {
  --vert:       #22c55e;
  --vert-dark:  #16a34a;
  --vert-bg:    #052e16;
  --rouge:      #ef4444;
  --rouge-bg:   #450a0a;
  --jaune:      #f59e0b;
  --fond:       #080f1a;
  --surface:    #0f1f35;
  --surface2:   #162840;
  --bordure:    #1e3a5f;
  --texte:      #e2e8f0;
  --texte-dim:  #64748b;
  --radius:     12px;
}

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--fond);
  color: var(--texte);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Lueur d'ambiance */
#bg-glow {
  position: fixed;
  top: -200px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse, rgba(34,197,94,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ===== HEADER ===== */
header {
  position: relative;
  z-index: 1;
  background: rgba(15, 31, 53, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
  padding: 16px 20px 14px;
  text-align: center;
}

#header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 760px;
  margin: 0 auto 10px;
}

#logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
#btn-retour {
  color: var(--texte-dim);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
#btn-retour:hover {
  color: var(--texte);
  background: var(--surface2);
}

.logo-icon { font-size: 26px; }
.logo-text {
  font-size: 24px;
  font-weight: 800;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

#header-actions { display: flex; gap: 8px; align-items: center; }

#btn-accueil {
  background: var(--surface2);
  color: var(--texte);
  border: 1px solid var(--bordure);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 15px;
  text-decoration: none;
  display: flex; align-items: center;
  transition: all 0.2s;
}
#btn-accueil:hover { background: var(--bordure); border-color: var(--vert); }

#header-actions button {
  background: var(--surface2);
  color: var(--texte);
  border: 1px solid var(--bordure);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s;
}
#header-actions button:hover {
  background: var(--bordure);
  border-color: var(--vert);
}

#sous-titre { color: #94a3b8; font-size: 14px; font-weight: 500; }
#date-affichee { color: var(--texte-dim); font-size: 12px; margin-top: 4px; }

/* ===== PANNEAU HISTORIQUE ===== */
#panneau-historique {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
#panneau-historique.cache { display: none; }

#panneau-inner {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 20px;
  padding: 24px;
  width: 360px;
  max-height: 75vh;
  overflow-y: auto;
}

#panneau-titre {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
#panneau-titre h2 { color: var(--vert); font-size: 18px; font-weight: 700; }

#btn-fermer-historique {
  background: none;
  border: none;
  color: var(--texte-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.2s;
}
#btn-fermer-historique:hover { color: var(--texte); }

#liste-historique { list-style: none; }
#liste-historique li {
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: #cbd5e1;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
#liste-historique li:hover { background: var(--surface2); }
#liste-historique li.actif { color: var(--vert); font-weight: 600; }
#liste-historique li.cal-win  { border-left: 3px solid var(--vert); color: #86efac; }
#liste-historique li.cal-lose { border-left: 3px solid var(--rouge); color: #fca5a5; }
#liste-historique li .cal-badge {
  font-size: 11px; font-weight: 700; opacity: 0.85;
}

/* ===== MAIN ===== */
main {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 28px auto;
  padding: 0 16px;
}

/* ===== SAISIE ===== */
#zone-saisie {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

#champ-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#loupe {
  position: absolute;
  left: 14px;
  font-size: 16px;
  pointer-events: none;
}

#champ-joueur {
  width: 100%;
  padding: 13px 16px 13px 42px;
  font-size: 16px;
  font-family: inherit;
  background: var(--surface);
  border: 2px solid var(--bordure);
  border-radius: var(--radius);
  color: var(--texte);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#champ-joueur:focus {
  border-color: var(--vert);
  box-shadow: 0 0 0 3px rgba(34,197,94,0.1);
}

#suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--radius);
  list-style: none;
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#suggestions.cache { display: none; }
#suggestions li {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 14px;
  color: #cbd5e1;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 10px;
}
#suggestions li:hover, #suggestions li.actif {
  background: var(--surface2);
  color: var(--vert);
}

#btn-deviner {
  background: linear-gradient(135deg, var(--vert), var(--vert-dark));
  color: #052e16;
  border: none;
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(34,197,94,0.25);
}
#btn-deviner:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(34,197,94,0.35);
}

/* ===== BARRE OUTILS ===== */
#barre-outils {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#compteur {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--texte-dim);
  font-size: 14px;
}
#nb-tentatives {
  font-size: 22px;
  font-weight: 800;
  color: var(--texte);
}

#btn-indice {
  background: var(--surface);
  border: 1px solid var(--bordure);
  color: var(--texte);
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}
#btn-indice:hover:not(:disabled) {
  border-color: var(--jaune);
  color: var(--jaune);
}
#btn-indice:disabled { opacity: 0.4; cursor: not-allowed; }

#btn-abandonner {
  background: var(--surface);
  border: 1px solid var(--bordure);
  color: var(--texte-dim);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
}
#btn-abandonner:hover:not(:disabled) {
  border-color: var(--rouge);
  color: var(--rouge);
}
#btn-abandonner:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== TOAST POINTS ===== */
.toast-points {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff; font-size: 18px; font-weight: 800;
  padding: 12px 28px; border-radius: 40px;
  box-shadow: 0 8px 24px rgba(245,158,11,0.4);
  z-index: 9999; opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.toast-points.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== MODALE ABANDON ===== */
#fg-abandon-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(8, 15, 26, 0.75);
  backdrop-filter: blur(4px);
  z-index: 900;
}
#fg-abandon-modal {
  display: none;
  position: fixed; inset: 0;
  align-items: center; justify-content: center;
  z-index: 901;
}
#fg-abandon-inner {
  background: #0f1f35;
  border: 1px solid #1e3a5f;
  border-radius: 20px;
  padding: 32px 28px;
  width: 320px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  animation: slideIn 0.2s ease;
}
.fg-abandon-icone { font-size: 40px; margin-bottom: 14px; }
#fg-abandon-titre { font-size: 18px; font-weight: 800; color: #e2e8f0; margin-bottom: 10px; }
#fg-abandon-desc  { font-size: 13px; color: #64748b; line-height: 1.6; margin-bottom: 24px; }
.fg-abandon-btns  { display: flex; gap: 10px; }
#fg-abandon-non {
  flex: 1; background: none; border: 1px solid #1e3a5f;
  color: #94a3b8; padding: 11px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
#fg-abandon-non:hover { border-color: #3b82f6; color: #e2e8f0; }
#fg-abandon-oui {
  flex: 1; background: rgba(239,68,68,0.1); border: 1px solid #ef4444;
  color: #ef4444; padding: 11px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
#fg-abandon-oui:hover { background: rgba(239,68,68,0.2); }

/* Bannière déjà joué */
#deja-joue-banner {
  background: linear-gradient(135deg, #052e16, #14532d);
  border: 1px solid #16a34a;
  border-radius: 16px;
  padding: 20px 24px;
  text-align: center;
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 16px; font-weight: 700; color: #86efac;
  animation: slideIn 0.4s ease;
}

/* Carte solution (abandon) */
#carte-solution {
  background: linear-gradient(135deg, #1a0a0a, #2d1010);
  border: 1px solid var(--rouge);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  margin-top: 20px;
  margin-bottom: 20px;
  animation: slideIn 0.4s ease;
}
#carte-solution h3 { color: #fca5a5; margin-bottom: 12px; font-size: 16px; }
#carte-solution .solution-nom { font-size: 26px; font-weight: 800; color: var(--texte); margin-bottom: 8px; }
#carte-solution .solution-details { color: #94a3b8; font-size: 13px; line-height: 2; }

#badge-indices {
  background: var(--jaune);
  color: #000;
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
}

/* ===== INDICES RÉVÉLÉS ===== */
#zone-indices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.carte-indice {
  background: linear-gradient(135deg, #1c2f1c, #0f1f35);
  border: 1px solid var(--vert-dark);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: slideIn 0.3s ease;
}
.carte-indice .indice-label {
  color: var(--texte-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.carte-indice .indice-valeur {
  color: var(--vert);
  font-weight: 700;
  font-size: 14px;
}

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

/* ===== TABLEAU ===== */
#tableau-header, .ligne-resultat {
  display: grid;
  grid-template-columns: 44px 1.6fr 1.1fr 0.7fr 1.2fr 1.1fr 1.6fr;
  gap: 5px;
  margin-bottom: 5px;
}
#tableau-header.cache { display: none; }

#tableau-header span {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--texte-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: center;
}

/* AVATAR */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: white;
  flex-shrink: 0;
  border: 2px solid var(--bordure);
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cellule {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  transition: all 0.2s;
  animation: flipIn 0.4s ease;
}

@keyframes flipIn {
  from { transform: rotateX(-90deg); opacity: 0; }
  to   { transform: rotateX(0deg);   opacity: 1; }
}

.cellule.correct   { background: var(--vert-bg);  border-color: var(--vert);  color: #86efac; }
.cellule.incorrect { background: var(--rouge-bg); border-color: var(--rouge); color: #fca5a5; }

.cellule-nom {
  background: var(--surface2) !important;
  border-color: var(--bordure) !important;
  color: var(--texte) !important;
  font-weight: 700;
  font-size: 12px;
}

.direction {
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}

/* ===== MODAL VICTOIRE ===== */
#message-victoire {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
#message-victoire.cache { display: none; }

#victoire-inner {
  background: linear-gradient(160deg, #0a1f0f, #0f1f35);
  border: 1px solid var(--vert-dark);
  border-radius: 24px;
  padding: 40px 32px 32px;
  width: 400px;
  max-width: calc(100vw - 32px);
  text-align: center;
  position: relative;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(34,197,94,0.1);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

#btn-fermer-victoire {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--surface2);
  border: 1px solid var(--bordure);
  color: var(--texte-dim);
  font-size: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}
#btn-fermer-victoire:hover { color: var(--texte); border-color: var(--texte-dim); }

#confetti { font-size: 52px; margin-bottom: 16px; animation: bounce 0.6s ease; }
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.3); }
}

#texte-victoire {
  font-size: 20px;
  font-weight: 700;
  color: #86efac;
  margin-bottom: 24px;
  line-height: 1.4;
}

#victoire-actions { display: flex; justify-content: center; gap: 12px; }

#btn-partager {
  background: var(--vert);
  color: #052e16;
  border: none;
  padding: 12px 32px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(34,197,94,0.3);
}
#btn-partager:hover { background: var(--vert-dark); transform: translateY(-1px); }

#confirmation-copie {
  color: #86efac;
  font-size: 13px;
  margin-top: 14px;
  font-weight: 600;
}
#confirmation-copie.cache { display: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--fond); }
::-webkit-scrollbar-thumb { background: var(--bordure); border-radius: 3px; }

/* Cacher la topbar (pseudo + langue) sur cette page */
#topbar-btns { display: none !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  header { padding: 12px 14px 10px; }
  .logo-text { font-size: 18px; }
  .logo-icon { font-size: 20px; }
  #sous-titre { font-size: 12px; }
  main { margin: 16px auto; padding: 0 12px; }

  /* Saisie */
  #zone-saisie { gap: 8px; }
  #champ-joueur { font-size: 16px; padding: 12px 12px 12px 38px; }
  #btn-deviner { padding: 12px 14px; font-size: 13px; }

  /* Barre outils */
  #barre-outils { gap: 8px; }
  #btn-indice, #btn-abandonner { font-size: 12px; padding: 8px 10px; }

  /* Tableau : 6 colonnes (sans avatar), pas de scroll horizontal */
  #tableau-header, .ligne-resultat {
    grid-template-columns: 1.2fr 0.75fr 0.38fr 0.65fr 0.75fr 0.9fr;
    gap: 3px;
  }
  /* Cacher colonne avatar (1ère) */
  .ligne-resultat > *:nth-child(1),
  #tableau-header span:nth-child(1) { display: none !important; }
  #tableau-header span:nth-child(6),
  #tableau-header span:nth-child(7),
  .ligne-resultat > *:nth-child(6),
  .ligne-resultat > *:nth-child(7) { display: flex; }
  .cellule {
    font-size: 9.5px;
    padding: 5px 2px;
    min-height: 32px;
    border-radius: 6px;
    border-width: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .cellule-nom { font-size: 9.5px; }
  #tableau-header span {
    font-size: 8px;
    padding: 4px 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Panneau historique plein écran */
  #panneau-inner { width: calc(100vw - 32px); max-height: 85vh; border-radius: 16px; padding: 18px; }

  /* Modal victoire */
  #victoire-inner { width: calc(100vw - 32px); padding: 24px 18px; }

  /* Modal abandon */
  #fg-abandon-inner { width: calc(100vw - 32px); }

  /* Toast points au-dessus de la navbar mobile */
  .toast-points { bottom: 72px; }
}
