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

/* Barre de scroll personnalisée */
* {
  scrollbar-width: thin;
  scrollbar-color: #8b6914 transparent;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c8960c, #8b6914);
  border-radius: 3px;
}

/* CRITIQUE — sans ça toutes les vues s'affichent en même temps */
.hidden { display: none !important; }

:root {
  --bg: #0f0f14;
  --surface: #1a1a24;
  --border: #2e2e42;
  --accent: #7c6af7;
  --text: #e8e6f0;
  --text-muted: #8a88a0;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
  --radius: 12px;
  /* Couleurs pour le fond beige du cadre — plus contrastées */
  --tc:       #1a0d04;
  --tc-muted: #4a3520;
  --tc-accent:#6b2d00;

  /* ═══════════════════════════════════════════════════════════════════
     VARIABLES POP-UPS — à ajuster pour caler le contenu sur fond_pop_up
     ═══════════════════════════════════════════════════════════════════ */

  /* Marges intérieures de la pop-up (zones inutilisables de fond_pop_up.png) */
  --popup-padding-top:    12%;
  --popup-padding-bottom: 12%;
  --popup-padding-left:   10%;
  --popup-padding-right:  10%;

  /* Largeur max des pop-ups */
  --popup-width:       300px;
  --popup-width-large: 360px;

  /* Taille du bouton Fermer */
  --popup-btn-fermer: 30px;
}

/* ─── Body ───────────────────────────────────────────────────────────────── */
body {
  background-image: url('/img/design/fond_mur2.png');
  background-repeat: repeat;
  background-size: auto;
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* ─── Layout page ────────────────────────────────────────────────────────── */
.page { width: 100%; max-width: 460px; }
.page.hidden { display: none !important; }
.page.active { display: flex; justify-content: center; }

.page-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Logo ───────────────────────────────────────────────────────────────── */
.logo-img {
  width: 210px;
  max-width: 65%;
  position: relative;
  z-index: 2;
  margin-bottom: 0px;
  margin-top: -1.5rem;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.6));
}

/* ─── Cadre wrapper ──────────────────────────────────────────────────────── */
.cadre-wrapper {
  position: relative;
  width: 100%;
}

.cadre-bg {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 0;
  pointer-events: none;
  /* On laisse l'image définir la hauteur naturellement */
}

/* ─── Contenu positionné par-dessus le cadre avec les marges exactes ──────
   Haut/Bas : 13% de la hauteur du cadre
   Gauche/Droite : 12% de la largeur du cadre
   ────────────────────────────────────────────────────────────────────────── */
.cadre-content {
  position: absolute;
  /* Marges calculées depuis les bords du cadre */
  top: 13%;
  bottom: 13%;
  left: 12%;
  right: 12%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.6rem;
  overflow: hidden; /* le cadre ne scroll pas globalement */
}

/* ─── Header déconnexion ─────────────────────────────────────────────────── */
.header-deconnexion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.btn-deconnexion img { height: 32px; width: auto; }
.btn-admin img       { height: 32px; width: auto; }
.btn-grimoire img    { height: 32px; width: auto; }

/* ─── Onglets vues ───────────────────────────────────────────────────────── */
.onglets-vues {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-shrink: 0;
}
.onglets-auth {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-shrink: 0;
}
.onglet-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  transition: transform 0.1s ease;
}
.onglet-btn:active,
.onglet-btn.pressed {
  transform: scale(0.93);
}
.onglet-btn img { height: 38px; width: auto; display: block; }

/* ─── Vues (éclats / récompenses) ───────────────────────────────────────── */
#view-eclats,
#view-rewards {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-height: 0; /* important pour que flex enfant puisse scroller */
}

/* ─── Vue récompenses — header fixe + liste scrollable ──────────────────── */
.rewards-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.rewards-titre {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--tc);
}
.rewards-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--tc-muted);
  cursor: pointer;
}
.rewards-toggle input { cursor: pointer; accent-color: var(--tc-accent); }

#rewards-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Barre de scroll thème médiéval */
  scrollbar-width: thin;
  scrollbar-color: #8b6914 transparent;
}
#rewards-list::-webkit-scrollbar { width: 6px; }
#rewards-list::-webkit-scrollbar-track { background: transparent; }
#rewards-list::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c8960c, #8b6914);
  border-radius: 3px;
}

/* ─── Items récompenses ──────────────────────────────────────────────────── */
.reward-item {
  background-image: url('/img/design/fond_recompenses.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 70px;
  width: 100%;
  box-sizing: border-box;
}
.reward-item.claimed { opacity: 0.55; }
.reward-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1;
}
.reward-combo { font-size: 0.8rem; font-weight: 700; color: var(--tc-accent); }
.reward-text  { font-size: 0.85rem; color: var(--tc); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reward-date  { font-size: 0.7rem; color: var(--tc-muted); }
.reward-status {
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  flex-shrink: 0;
}
.status-pending { background: rgba(139,69,19,0.15); color: var(--tc-accent); }
.status-claimed { background: rgba(74,222,128,0.2); color: #2d6a3f; }

/* ─── Vue éclats ─────────────────────────────────────────────────────────── */
.welcome-txt {
  font-size: 0.82rem;
  color: var(--tc-muted);
  text-align: center;
  flex-shrink: 0;
}
.welcome-txt span { color: var(--tc); font-weight: 600; }

.eclat-box-wrapper {
  position: relative;
  width: 80%;
  margin: 0 auto;
  flex-shrink: 0;
}
.fond-eclats-bg { display: block; width: 100%; height: auto; }
.eclat-box-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.eclat-count {
  font-size: 3rem;
  font-weight: 700;
  color: var(--tc-accent);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.eclat-label {
  font-size: 0.78rem;
  color: var(--tc-muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

#zone-scan { flex-shrink: 0; }
.scan-instruction {
  font-size: 0.85rem;
  text-align: center;
  color: var(--tc-muted);
  padding: 0.25rem 0;
}
.cooldown-txt {
  font-size: 0.82rem;
  color: var(--tc-muted);
  text-align: center;
}
.dernier-scan {
  font-size: 0.75rem;
  color: var(--tc-muted);
  text-align: center;
  flex-shrink: 0;
}

#zone-slot { flex-shrink: 0; display: flex; justify-content: center; }
.btn-lancer-bandit img { height: 50px; width: auto; }

/* ─── Messages ───────────────────────────────────────────────────────────── */
.msg {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
  flex-shrink: 0;
  font-weight: 600;
}
/* Couleurs adaptées au fond beige — bien contrastées */
.msg.error   { background: rgba(180,30,30,0.12);  color: #8b0000; border: 1px solid rgba(180,30,30,0.3); }
.msg.success { background: rgba(0,100,30,0.12);   color: #004d1a; border: 1px solid rgba(0,100,30,0.3); }
.msg.warning { background: rgba(120,80,0,0.12);   color: #5a3a00; border: 1px solid rgba(120,80,0,0.3); }
.msg.hidden  { display: none !important; }

/* ─── Page login — champs et boutons ────────────────────────────────────── */
.titre-cadre {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--tc);
  text-align: center;
  flex-shrink: 0;
}
.sous-titre-cadre {
  font-size: 0.85rem;
  color: var(--tc-muted);
  text-align: center;
  flex-shrink: 0;
}
.form-auth {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  width: 100%;
}

/* Espacement plus généreux uniquement sur la page login */
#page-login .form-auth { gap: 0.85rem; }
#page-login .champ-wrapper input {
  padding: 0.9rem 2.5rem 0.9rem 19%;
  font-size: 1.05rem;
}

.form-auth-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 0.3rem; }
#page-login .btn-img img { height: 52px; }
.champ-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.champ-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('/img/design/champs_texte_clair.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
}
.champ-wrapper input {
  position: relative;
  z-index: 1;
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.65rem 2.5rem 0.65rem 19%;
  font-size: 0.95rem;
  color: #ffffff;
  font-family: inherit;
}
.champ-wrapper input::placeholder { color: rgba(255,255,255,0.55); }

/* Supprime le fond blanc de l'autofill navigateur */
.champ-wrapper input:-webkit-autofill,
.champ-wrapper input:-webkit-autofill:hover,
.champ-wrapper input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px transparent inset;
  box-shadow: 0 0 0px 1000px transparent inset;
  -webkit-text-fill-color: #ffffff;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: #ffffff;
}

/* Bouton œil — blanc */
.btn-oeil {
  position: absolute;
  right: 0.75rem;
  z-index: 2;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.7;
  padding: 0.2rem;
  line-height: 1;
  transition: opacity 0.15s;
  color: #ffffff;
  filter: brightness(10);
}
.btn-oeil:hover { opacity: 1; }
.btn-oeil.visible { opacity: 1; }

.btn-img {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-img img { display: block; height: 44px; width: auto; }
.btn-img:active img { transform: scale(0.97); }

.onglet-btn img { height: 44px; width: auto; display: block; }

/* ─── Admin — override ───────────────────────────────────────────────────── */
body.admin-page {
  background-image: none !important;
  background: var(--bg) !important;
  display: block !important;
  overflow: auto !important;
  height: auto !important;
  padding: 0 !important;
}
body.admin-page .page { max-width: 400px; margin: 0 auto; }
body.admin-page #page-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
body.admin-page .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  width: 100%;
}
body.admin-page .card .logo {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--accent);
}
body.admin-page h1 {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--text);
}
body.admin-page .subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
body.admin-page input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.75rem;
  outline: none;
}
body.admin-page input:focus { border-color: var(--accent); }
body.admin-page .btn-primary {
  width: 100%;
  padding: 0.85rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}
body.admin-page .btn-primary:hover { background: #6b59e6; }

.section-desc { color: var(--text-muted); font-size: 0.9rem; }

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {

  /* Cadre plus haut sur mobile — force le PNG à s'étirer verticalement */
  .cadre-wrapper {
    min-height: 70vh;
  }
  .cadre-bg {
    height: 100%;
    object-fit: fill;
  }

  /* Boutons plus petits */
  .onglet-btn img        { height: 32px; }
  .btn-deconnexion img   { height: 26px; }
  .btn-grimoire img      { height: 26px; }
  .btn-lancer-bandit img { height: 38px; }
  .btn-img img           { height: 36px; }

  /* Réduire le gap général dans le cadre */
  .cadre-content { gap: 0.4rem; }

  /* Éclats légèrement réduit */
  .eclat-box-wrapper { width: 70%; }
  .eclat-count       { font-size: 2.4rem; }
  .eclat-label       { font-size: 0.7rem; }
}

/* ─── Bouton admin ───────────────────────────────────────────────────────── */
.btn-admin {
  background: rgba(139,69,19,0.25);
  border: 1px solid rgba(139,69,19,0.5);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}
.btn-admin-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--tc-accent);
  white-space: nowrap;
}
.btn-admin:hover { background: rgba(139,69,19,0.4); }

@media (max-width: 480px) {
  .btn-admin-label { font-size: 0.7rem; }
}

/* ─── Bouton chargement (login) ──────────────────────────────────────────── */
.btn-loading-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-loading-wrapper img {
  display: block;
  height: 44px;
  width: auto;
}
.btn-spinner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(139,69,19,0.25);
  border-top-color: var(--tc-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  pointer-events: none;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Feedback clic bouton img ───────────────────────────────────────────── */
.btn-img.pressed img,
.btn-img:active img {
  transform: scale(0.93);
}

/* ─── Liens texte dans le cadre ──────────────────────────────────────────── */
.lien-mdp-oublie,
.lien-confidentialite {
  text-align: center;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.lien-mdp-oublie span,
.lien-confidentialite span {
  color: var(--tc-muted);
  text-decoration: underline;
  cursor: pointer;
  transition: color 0.15s;
}
.lien-mdp-oublie span:hover,
.lien-confidentialite span:hover { color: var(--tc-accent); }

/* ─── Pop-ups génériques (mdp oublié, confidentialité) ───────────────────── */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: slot-fadein 0.2s ease;
}
.popup-overlay.hidden { display: none !important; }

.popup-fond {
  position: relative;
  width: 90%;
  max-width: var(--popup-width);
}
.popup-fond-large {
  width: 92%;
  max-width: var(--popup-width-large);
}

.popup-bg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.popup-contenu {
  position: relative;
  z-index: 1;
  padding: var(--popup-padding-top) var(--popup-padding-right) var(--popup-padding-bottom) var(--popup-padding-left);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

/* Bouton fermer — taille réglable via --popup-btn-fermer */
.popup-contenu .btn-img img { height: var(--popup-btn-fermer) !important; width: auto; }

.popup-titre {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--tc);
  text-align: center;
  flex-shrink: 0;
}

.popup-texte {
  font-size: 0.75rem;
  color: var(--tc-muted);
  text-align: center;
  line-height: 1.5;
  flex-shrink: 0;
}

.popup-scroll {
  overflow-y: auto;
  text-align: left;
  width: 100%;
  max-height: 25vh;
  scrollbar-width: thin;
  scrollbar-color: #8b6914 transparent;
}
.popup-scroll::-webkit-scrollbar { width: 4px; }
.popup-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c8960c, #8b6914);
  border-radius: 2px;
}
.popup-scroll p {
  margin-bottom: 0.6rem;
  font-size: 0.72rem;
  color: var(--tc-muted);
  line-height: 1.5;
}
.popup-scroll strong { color: var(--tc); }
