/* assets/css/style.css — TTCM, mobile-first */

/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --violet:  #5B2D8E;
  --violet-l:#EDE8FF;
  --orange:  #C95B0C;
  --orange-l:#FFF0E6;
  --bleu:    #1A5EA8;
  --bleu-l:  #E6F1FB;
  --vert:    #1E7A3E;
  --vert-l:  #EAF3DE;
  --challenge:#8B1428;
  --challenge-l:#FCEAED;

  --gris-bg:   #F4F3EF;
  --gris-card: #FFFFFF;
  --gris-bord: rgba(0,0,0,0.12);
  --gris-texte:#2C2C2A;
  --gris-doux: #6B6A66;
  --gris-hint: #9B9A96;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --ombre: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Reset minimal ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gris-bg);
  color: var(--gris-texte);
  line-height: 1.5;
  min-height: 100dvh;
}

/* ── Layout de base ────────────────────────────────────────────── */
.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 80px;  /* espace bas pour ne pas couvrir les boutons fixes */
}

.page-header {
  background: var(--gris-card);
  border-bottom: 1px solid var(--gris-bord);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-header h1 {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
}

.page-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Carte ─────────────────────────────────────────────────────── */
.carte {
  background: var(--gris-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--gris-bord);
  padding: 16px;
}

.carte-titre {
  font-size: 13px;
  font-weight: 600;
  color: var(--gris-doux);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

/* ── Formulaires ───────────────────────────────────────────────── */
.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 14px;
  font-weight: 500;
  color: var(--gris-doux);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--gris-bord);
  border-radius: var(--radius-sm);
  font-size: 16px;   /* évite le zoom auto iOS */
  color: var(--gris-texte);
  background: var(--gris-card);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(91,45,142,0.15);
}

input.erreur, select.erreur {
  border-color: #C0392B;
}

.msg-erreur {
  font-size: 13px;
  color: #C0392B;
}

.msg-succes {
  font-size: 13px;
  color: var(--vert);
}

/* ── Boutons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primaire {
  background: var(--violet);
  color: #fff;
  width: 100%;
}

.btn-secondaire {
  background: transparent;
  color: var(--violet);
  border: 1px solid var(--violet);
  width: 100%;
}

.btn-danger {
  background: #C0392B;
  color: #fff;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ── Toggle (interrupteur) ─────────────────────────────────────── */
.toggle-ligne {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.toggle-label { font-size: 15px; }

.toggle {
  position: relative;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-piste {
  position: absolute;
  inset: 0;
  background: var(--gris-bord);
  border-radius: 14px;
  transition: background 0.2s;
}

.toggle input:checked + .toggle-piste { background: var(--violet); }

.toggle-piste::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle input:checked + .toggle-piste::after { transform: translateX(22px); }

/* ── En-tête de jeu coloré selon catégorie ─────────────────────── */
.jeu-header {
  padding: 12px 14px 10px;
  color: #fff;
}

.jeu-header.violette { background: var(--violet); }
.jeu-header.orange   { background: var(--orange); }
.jeu-header.bleue    { background: var(--bleu); }
.jeu-header.verte    { background: var(--vert); }
.jeu-header.challenge{ background: var(--challenge); }

.jeu-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.jeu-titre {
  font-size: 15px;
  font-weight: 600;
}

.jeu-btns { display: flex; gap: 8px; }

.jeu-btn-icone {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.jeu-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.jeu-meta-cell {
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 5px 8px;
  text-align: center;
}

.jeu-meta-label {
  display: block;
  font-size: 10px;
  opacity: 0.75;
  margin-bottom: 1px;
}

.jeu-meta-val {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

/* ── Ligne lecteur ─────────────────────────────────────────────── */
.lecteur-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gris-bg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin: 8px 8px;
  border: 1px solid var(--gris-bord);
}

.lecteur-nom   { font-size: 16px; font-weight: 600; flex: 1; }
.lecteur-chall { font-size: 12px; color: var(--gris-doux); white-space: nowrap; }
.lecteur-div   { width: 1px; height: 14px; background: var(--gris-bord); }
.lecteur-score { font-size: 15px; font-weight: 600; color: var(--violet); white-space: nowrap; }

/* ── Tableau joueurs ───────────────────────────────────────────── */
.joueurs-table {
  width: 100%;
  border-collapse: collapse;
}

.joueurs-table thead th {
  font-size: 10px;
  color: var(--gris-hint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 4px 6px 6px;
  text-align: center;
  font-weight: 500;
}

.joueurs-table thead th:nth-child(2) { text-align: left; }

.joueurs-table tbody tr {
  border-top: 1px solid var(--gris-bord);
}

.joueurs-table tbody td {
  padding: 8px 4px;
  vertical-align: middle;
  text-align: center;
}

.joueurs-table tbody td:nth-child(2) { text-align: left; }

.td-gagne  { width: 44px; }
.td-nom    { font-size: 13px; font-weight: 500; }
.td-score  { font-size: 14px; font-weight: 600; width: 44px; }
.td-chall  { font-size: 12px; color: var(--gris-doux); width: 36px; }
.td-niveau { width: 88px; }

/* Bouton trophée */
.btn-gagne {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gris-bord);
  background: var(--gris-card);
  color: var(--gris-hint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}

.btn-gagne.actif {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}

.btn-gagne:disabled { opacity: 0.25; pointer-events: none; }

/* Contrôle de niveau +/- */
.niveau-ctrl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.niveau-btn {
  width: 26px; height: 30px;
  border-radius: 6px;
  padding: 20px 20px;
  border: 1px solid var(--gris-bord);
  background: var(--gris-bg);
  color: var(--gris-texte);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.niveau-val {
  min-width: 22px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--violet);
}

.niveau-val.vide { color: var(--gris-hint); font-size: 12px; font-weight: 400; }
.niveau-val.pris { color: var(--gris-hint); font-size: 12px; }  /* exclusif : niveau pris */

/* ── Modale de confirmation ────────────────────────────────────── */
.modale-fond {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;       /* slide up depuis le bas, idiome mobile */
  justify-content: center;
  padding: 0;
}

.modale-fond.cache { display: none; }

.modale-boite {
  background: var(--gris-card);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-lg);
  padding: 10px 10px 10px;
  width: 90%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modale-titre {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.modale-texte {
  font-size: 15px;
  color: var(--gris-doux);
  text-align: center;
  line-height: 1.6;
}

/* ── QR Code overlay ───────────────────────────────────────────── */
.qr-fond {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.qr-fond.cache { display: none; }

.qr-boite {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
}

.qr-url {
  font-size: 13px;
  color: var(--gris-doux);
  margin-top: 8px;
  word-break: break-all;
}

/* ── Lien retour ───────────────────────────────────────────────── */
.lien-retour {
  font-size: 22px;
  color: var(--gris-doux);
  text-decoration: none;
  line-height: 1;
  padding: 4px;
}

/* ── Divers ────────────────────────────────────────────────────── */
.separateur {
  height: 1px;
  background: var(--gris-bord);
}

.texte-centre { text-align: center; }
.texte-doux   { color: var(--gris-doux); }
.texte-sm     { font-size: 14px; }

a { color: var(--violet); text-decoration: none; }
a:active { opacity: 0.7; }

/* ── Page publique ─────────────────────────────────────────────── */
.public-header {
  background: var(--violet);
  color: #fff;
  padding: 20px 16px 16px;
  text-align: center;
}

.public-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.public-sous-titre { font-size: 13px; opacity: 0.8; }

.score-ligne {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--gris-bord);
  gap: 12px;
}

.score-ligne:last-child { border-bottom: none; }

.score-rang {
  width: 28px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--gris-hint);
  flex-shrink: 0;
}

.score-rang.premier { color: #B8860B; }

.score-nom    { flex: 1; font-size: 16px; font-weight: 500; }
.score-chall  { font-size: 12px; color: var(--gris-doux); }
.score-pts    { font-size: 22px; font-weight: 700; color: var(--violet); min-width: 48px; text-align: right; }

/* ── Historique ────────────────────────────────────────────────── */
.histo-partie {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.histo-date  { font-size: 12px; color: var(--gris-hint); }
.histo-nom   { font-size: 15px; font-weight: 600; }
.histo-detail{ font-size: 13px; color: var(--gris-doux); }
