@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&display=swap');

:root {
  --fond: #1c1424;
  --fond-2: #120c18;
  --carte: #2a1e35;
  --carte-haut: #34263f;
  --carte-bordure: rgba(201, 162, 39, 0.14);
  --accent: #c9a227;
  --accent-clair: #e2c25a;
  --texte: #f2ece0;
  --texte-att: #b8adc4;
  --erreur: #e2637b;
  --vert: #5fa878;
  --ombre: rgba(0, 0, 0, 0.32);
  --font-titre: 'Fredoka', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at 50% -12%, var(--carte-haut) 0%, var(--fond) 42%, var(--fond-2) 100%);
  background-attachment: fixed;
  color: var(--texte);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 460px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hidden { display: none; }

#btn-musique {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 10px);
  right: calc(env(safe-area-inset-right) + 10px);
  z-index: 50;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(42, 30, 53, 0.82);
  border: 1px solid var(--carte-bordure);
  color: var(--texte);
  font-size: 1.05rem;
  line-height: 40px;
  box-shadow: 0 4px 14px var(--ombre);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#btn-musique:hover:not(:disabled),
#btn-musique:active:not(:disabled) { box-shadow: 0 4px 14px var(--ombre); }

#btn-musique.muet { opacity: 0.5; }

@keyframes apparition-ecran {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen:not(.hidden) {
  animation: apparition-ecran 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

h1 {
  font-family: var(--font-titre);
  font-weight: 600;
  font-size: 1.9rem;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  text-align: center;
}

.sous-titre {
  text-align: center;
  color: var(--texte-att);
  margin-top: 0;
  margin-bottom: 24px;
}

.carte {
  background: linear-gradient(165deg, var(--carte-haut) 0%, var(--carte) 55%);
  border: 1px solid var(--carte-bordure);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px var(--ombre);
}

.carte h2 {
  margin-top: 0;
  font-size: 1.05rem;
  font-family: var(--font-titre);
  font-weight: 600;
  letter-spacing: 0.2px;
}

input, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #3a2c47;
  color: var(--texte);
  font-size: 1rem;
  margin-bottom: 10px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

input::placeholder { color: var(--texte-att); }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

button {
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--accent-clair), var(--accent));
  color: #1c1424;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(201, 162, 39, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover:not(:disabled) {
  box-shadow: 0 8px 20px rgba(201, 162, 39, 0.3);
}

button:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 3px 10px rgba(201, 162, 39, 0.22);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.erreur {
  color: var(--erreur);
  text-align: center;
  font-size: 0.9rem;
}

.erreur.hidden { display: none; }

.liste-joueurs {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
}

.liste-joueurs li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--carte);
  border: 1px solid var(--carte-bordure);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: background 0.15s ease;
}

.joueur-pastille {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  background: #555;
}

.joueur-pastille.connecte {
  background: var(--vert);
  box-shadow: 0 0 0 0 rgba(95, 168, 120, 0.55);
  animation: pouls-connecte 2.2s infinite;
}

@keyframes pouls-connecte {
  0% { box-shadow: 0 0 0 0 rgba(95, 168, 120, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(95, 168, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(95, 168, 120, 0); }
}

.joueur-hote {
  font-size: 0.75rem;
  color: var(--accent);
  margin-left: 6px;
  letter-spacing: 0.3px;
}

#lobby-code {
  color: var(--accent);
  letter-spacing: 3px;
  font-family: var(--font-titre);
}

.carte-secrete {
  text-align: center;
}

.carte-secrete button {
  margin-top: 6px;
}

@keyframes reveal-pop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

#ep-role-revele:not(.hidden), #ep-reveal:not(.hidden) {
  animation: reveal-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ep-role-libelle {
  font-family: var(--font-titre);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.ep-role-libelle.paysan { color: var(--vert); }
.ep-role-libelle.intrus { color: var(--erreur); }

.ep-role-mot {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0;
}

.ep-role-consigne {
  font-size: 0.8rem;
  color: var(--texte-att);
}

.liste-tour {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.liste-tour li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #3a2c47;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.liste-tour li.tour-actif {
  background: #45304f;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.historique-tour {
  margin-bottom: 10px;
  padding-left: 10px;
  border-left: 2px solid var(--carte-bordure);
}

.historique-tour-titre {
  font-size: 0.75rem;
  color: var(--texte-att);
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.historique-tour-contenu {
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
}

.liste-vote {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.liste-vote li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #3a2c47;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 0.95rem;
  transition: background 0.2s ease;
}

.vote-votants {
  flex: 1;
  text-align: right;
  font-size: 0.8rem;
  color: var(--texte-att);
  margin-right: 6px;
}

.btn-voter {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.ep-tag-revote {
  font-size: 0.85rem;
  color: var(--erreur);
  font-weight: 400;
}

.liste-revelation {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.liste-revelation li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--carte);
  border: 1px solid var(--carte-bordure);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.liste-revelation li.revelation-eliminee {
  opacity: 0.6;
}

.revelation-role {
  font-size: 0.85rem;
  font-weight: 700;
}

.revelation-role.paysan { color: var(--vert); }
.revelation-role.intrus { color: var(--erreur); }

#go-titre {
  font-family: var(--font-titre);
}

#screen-game-over.gagnant-paysans #go-titre { color: var(--vert); }
#screen-game-over.gagnant-intrus #go-titre { color: var(--erreur); }

.btn-quitter {
  background: none;
  box-shadow: none;
  border: 1px solid var(--erreur);
  color: var(--erreur);
  margin-top: 16px;
}

.btn-quitter:hover:not(:disabled) { box-shadow: none; }

.btn-hote-discret {
  background: none;
  box-shadow: none;
  border: 1px dashed var(--texte-att);
  color: var(--texte-att);
  font-size: 0.8rem;
  padding: 8px 12px;
  margin-top: 8px;
}

.btn-hote-discret:hover:not(:disabled) { box-shadow: none; }

.btn-exclure {
  width: auto;
  padding: 4px 8px;
  background: none;
  box-shadow: none;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Réglages hôte au lobby (chrono par tour) */
.lobby-reglages {
  background: var(--carte);
  border: 1px solid var(--carte-bordure);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.reglage-toggle {
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  cursor: pointer;
}

.reglage-toggle input[type="checkbox"] {
  width: auto;
  margin: 0 10px 0 0;
  padding: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

#opt-chrono-duree { margin-top: 10px; margin-bottom: 0; }

/* Chrono du tour d'indices */
.chrono-tour {
  text-align: center;
  font-family: var(--font-titre);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  color: var(--accent-clair);
  background: #3a2c47;
  border: 1px solid var(--carte-bordure);
  border-radius: 999px;
  padding: 6px 14px;
  margin: 0 auto 12px;
  width: fit-content;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.chrono-tour.urgent {
  color: #fff;
  background: var(--erreur);
  border-color: var(--erreur);
  animation: chrono-pouls 1s ease-in-out infinite;
}

.chrono-tour.ecoule {
  color: var(--texte-att);
  background: var(--carte);
  font-size: 0.9rem;
  animation: none;
}

@keyframes chrono-pouls {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Historique du salon */
.historique-salon {
  margin: 16px 0 0;
  background: var(--carte);
  border: 1px solid var(--carte-bordure);
  border-radius: 12px;
  padding: 4px 14px;
  font-size: 0.9rem;
}

.historique-salon > summary {
  cursor: pointer;
  padding: 10px 0;
  font-family: var(--font-titre);
  font-weight: 600;
  color: var(--texte-att);
  list-style-position: inside;
}

.historique-salon[open] > summary { color: var(--texte); margin-bottom: 6px; }

.historique-corps { padding-bottom: 10px; }

.histo-parties { list-style: none; padding: 0; margin: 0 0 12px; }

.histo-partie {
  padding: 8px 0;
  border-bottom: 1px solid var(--carte-bordure);
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  align-items: baseline;
}

.histo-partie:last-child { border-bottom: none; }

.histo-num { color: var(--texte-att); font-size: 0.8rem; }

.histo-theme { font-weight: 600; }

.histo-issue { width: 100%; font-size: 0.82rem; color: var(--texte-att); }

.histo-partie.intrus .histo-issue { color: var(--erreur); }
.histo-partie.paysan .histo-issue { color: var(--vert); }

.histo-stats { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

.histo-stats th, .histo-stats td {
  text-align: right;
  padding: 5px 6px;
  border-bottom: 1px solid var(--carte-bordure);
}

.histo-stats th:first-child, .histo-stats td:first-child { text-align: left; }

.histo-stats th { color: var(--texte-att); font-weight: 600; }

/* CLUF + signalement (Guideline App Store 1.2) */
/* `:not(.hidden)` obligatoire : un sélecteur d'ID l'emporterait sinon sur
   `.hidden { display: none }` et l'overlay resterait affiché en permanence. */
#eula-overlay:not(.hidden), #report-overlay:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 6, 14, 0.92);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.eula-box, .report-box {
  background: linear-gradient(165deg, var(--carte-haut) 0%, var(--carte) 60%);
  border: 1px solid var(--carte-bordure);
  border-radius: 16px;
  padding: 22px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.eula-box h2, .report-box h2 {
  font-family: var(--font-titre);
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--accent-clair);
}

.eula-scroll {
  max-height: 46vh;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.55;
  padding-right: 6px;
  margin-bottom: 16px;
}

.eula-scroll strong { color: var(--accent-clair); }

.eula-actions, .report-actions {
  display: flex;
  gap: 10px;
}

.eula-actions button, .report-actions button { margin-top: 0; }

.report-box label {
  display: block;
  font-size: 0.85rem;
  color: var(--texte-att);
  margin: 12px 0 4px;
}

.report-flag {
  width: auto;
  padding: 0 4px;
  background: none;
  box-shadow: none;
  color: var(--erreur);
  font-size: 0.9rem;
  opacity: 0.75;
  vertical-align: baseline;
}

.report-flag:hover:not(:disabled) { box-shadow: none; opacity: 1; }

.accueil-pied {
  text-align: center;
  font-size: 0.82rem;
  color: var(--texte-att);
  margin-top: 18px;
}

.accueil-pied a { color: var(--texte-att); }

.partie-pied {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
}

.partie-pied button { margin-top: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
