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

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #e1e4e8;
  --text:      #1a1a2e;
  --muted:     #6b7280;
  --primary:   #2563eb;
  --success:   #16a34a;
  --danger:    #dc2626;
  --radius:    12px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --transition: 150ms ease;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  padding: 0 0 2rem;
}

/* ============================================================
   Layout helpers
   ============================================================ */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem;
}

.screen { width: 100%; }
.hidden { display: none !important; }

/* ============================================================
   Header
   ============================================================ */
.app-header {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.app-header h1 { font-size: 1.8rem; font-weight: 800; letter-spacing: -.5px; }
.app-header .subtitle {
  margin-top: .5rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.5;
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Forms
   ============================================================ */
label {
  display: block;
  font-weight: 600;
  margin-bottom: .4rem;
  font-size: .9rem;
}

input[type="text"] {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: .8rem;
}
input[type="text"]:focus { border-color: var(--primary); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: block;
  width: 100%;
  padding: .7rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: .88; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: .88; }

/* ============================================================
   Error
   ============================================================ */
.error { color: var(--danger); font-size: .88rem; margin-top: .5rem; }

/* ============================================================
   Lobby — joueurs
   ============================================================ */
#lobby-players {
  list-style: none;
  margin-bottom: 1.2rem;
}
#lobby-players li {
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
#lobby-players li:last-child { border-bottom: none; }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
  margin-top: .6rem;
}

/* ============================================================
   Scoreboard
   ============================================================ */
.scoreboard {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  padding: .9rem 1rem;
}
.score-chip {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: .35rem 1rem;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .35rem;
  transition: background .3s, border-color .3s;
}
.score-val { color: var(--muted); font-size: .82rem; }
.score-stars { font-size: .78rem; letter-spacing: 1px; }
.score-chip.me {
  border-color: var(--primary);
  background: #eff6ff;
}
/* Animation quand le score monte */
@keyframes scoreUp {
  0%   { transform: scale(1);    background: var(--bg); }
  30%  { transform: scale(1.18); background: #dcfce7; border-color: #16a34a; }
  100% { transform: scale(1);    background: var(--bg); }
}
.score-chip.score-up {
  animation: scoreUp .6s ease;
  border-color: #16a34a !important;
}

/* ============================================================
   Result banner
   ============================================================ */
/* ============================================================
   Result banner — deux variantes
   ============================================================ */
.result-banner {
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  font-size: .95rem;
  line-height: 1.6;
  animation: slideIn .25s ease;
}
.result-banner a { color: inherit; word-break: break-all; text-decoration: underline; }

.banner-mine {
  background: #f0fdf4;
  border: 1.5px solid #86efac;
  color: #166534;
}
.banner-other {
  background: #fef9c3;
  border: 1.5px solid #fde047;
  color: #854d0e;
}

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

/* ============================================================
   Question card
   ============================================================ */
.question-card { }

.theme-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 1rem;
}

.phrase {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.55;
  margin-bottom: 1.4rem;
}

/* ============================================================
   Answer buttons
   ============================================================ */
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

@media (max-width: 400px) {
  .answers { grid-template-columns: 1fr; }
}

.btn-answer {
  display: block;
  width: 100%;
  padding: .75rem .6rem;
  border: none;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.btn-answer:hover:not(:disabled):not(.wrong) { opacity: .88; }
.btn-answer:active:not(:disabled):not(.wrong) { transform: scale(.96); }

.btn-answer.wrong {
  background: #9ca3af !important;
  cursor: not-allowed;
  opacity: .6;
  text-shadow: none;
}
.btn-answer:disabled { cursor: not-allowed; opacity: .55; }

/* Choix du joueur en attente de revelation */
.btn-answer.my-choice {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(255,255,255,.5);
  opacity: 1 !important;
}

/* Bonne reponse revealee */
.btn-answer.correct-flash {
  outline: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(22,163,74,.6);
}

/* Banniere en attente */
.banner-waiting {
  background: #fefce8;
  border: 1.5px solid #fde047;
  color: #713f12;
}
.answer-counter {
  font-size: 1.05em;
  margin-left: .3rem;
}

/* Tableau de resultats apres revelation */
.results-table {
  margin-top: .7rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .9rem;
  gap: .5rem;
}
.result-pseudo { flex: 1; }
.result-choice {
  padding: .2rem .6rem;
  border-radius: 6px;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.reveal-answer {
  font-size: 1rem;
  margin-bottom: .3rem;
}
.reveal-expl {
  font-size: .85rem;
  color: inherit;
  opacity: .85;
  margin: .3rem 0;
}
.reveal-src {
  font-size: .82rem;
  margin-bottom: .4rem;
}
.reveal-src a { color: inherit; text-decoration: underline; }

.btn-next {
  display: block;
  width: 100%;
  margin-top: .9rem;
  padding: .7rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-next:hover:not(:disabled) { opacity: .88; }
.btn-next:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   Reset bar (toujours visible, discret en bas)
   ============================================================ */
#reset-bar {
  text-align: center;
  padding: .5rem 0 1rem;
  margin-top: .5rem;
}

.btn-reset {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: var(--muted);
  font-size: .78rem;
  padding: .35rem .9rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-reset:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: #fef2f2;
}
.victory-card { text-align: center; margin-top: 3rem; }
.trophy { font-size: 3.5rem; margin-bottom: .75rem; }
.victory-card h2 { font-size: 1.6rem; margin-bottom: 1.5rem; }

.final-scores {
  margin-bottom: 1.5rem;
}
.final-score-row {
  display: flex;
  justify-content: space-between;
  padding: .45rem .2rem;
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.final-score-row:last-child { border-bottom: none; }
.final-score-row .pts { font-weight: 700; color: var(--primary); }
