/* ============================================================
   BASE — reset, variables, typographie, écran d'authentification
   ============================================================ */

:root {
  /* Fonds */
  --bg:        #060d07;
  --bg-haut:   #0a1409;
  --panel:     #0f1a10;
  --panel2:    #192b1a;
  --panel3:    #21381f;
  --border:    #2a4a2c;
  --border-fort:#3d6640;

  /* Accents */
  --green:     #5fa862;
  --greenGlow: #7dd17f;
  --gold:      #c9a84c;
  --goldDim:   #6b5520;
  --danger:    #c45c52;
  --warn:      #d99a4e;
  --dignity:   #9b7fc7;

  /* Ressources */
  --kama:      #e0b84c;
  --reput:     #c78fd1;
  --food:      #d98d5c;
  --don:       #7fc7c0;

  /* Texte */
  --text:      #e8e0c8;
  --muted:     #8a9e86;
  --faint:     #5d7059;

  /* Héros */
  --elo:  #e8a4c8;
  --miko: #7dd17f;
  --ju:   #c9a84c;

  /* Métriques */
  --r-s:  10px;
  --r-m:  16px;
  --r-l:  22px;
  --gap:  14px;
  --safe-bas: env(safe-area-inset-bottom, 0px);
  --safe-haut: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body.modal-ouverte { overflow: hidden; }

h1, h2, h3 { font-family: 'Cinzel', Georgia, serif; font-weight: 700; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
button { background: none; border: none; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .85em;
  background: rgba(255,255,255,.06);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ============================================================
   ÉCRAN D'AUTHENTIFICATION
   ============================================================ */
#ecranAuth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 22px calc(24px + var(--safe-bas));
  background: radial-gradient(ellipse at 50% 26%, #0d2410 0%, var(--bg) 68%);
  overflow-y: auto;
}
#ecranAuth[hidden] { display: none; }

.auth-blason {
  font-size: 2.6rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 0 14px rgba(201,168,76,.35));
}

.auth-titre {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  letter-spacing: .03em;
  margin-bottom: 8px;
}

.auth-sous {
  color: var(--muted);
  font-size: .92rem;
  text-align: center;
  margin-bottom: 34px;
  line-height: 1.5;
}

.cartes-heros {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  width: 100%;
  max-width: 360px;
}
.cartes-heros[hidden] { display: none; }

.carte-heros-auth {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  padding: 17px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  transition: border-color .18s, transform .12s, box-shadow .18s;
}
.carte-heros-auth:active { transform: scale(.98); }

.carte-heros-auth[data-heros="Elo"]  { border-color: rgba(232,164,200,.35); }
.carte-heros-auth[data-heros="Miko"] { border-color: rgba(125,209,127,.35); }
.carte-heros-auth[data-heros="Ju"]   { border-color: rgba(201,168,76,.35); }

.carte-heros-auth[data-heros="Elo"]:hover  { box-shadow: 0 0 0 1px rgba(232,164,200,.5), 0 8px 24px -12px rgba(232,164,200,.6); }
.carte-heros-auth[data-heros="Miko"]:hover { box-shadow: 0 0 0 1px rgba(125,209,127,.5), 0 8px 24px -12px rgba(125,209,127,.6); }
.carte-heros-auth[data-heros="Ju"]:hover   { box-shadow: 0 0 0 1px rgba(201,168,76,.5),  0 8px 24px -12px rgba(201,168,76,.6); }

.auth-avatar { font-size: 2.3rem; line-height: 1; }
.auth-info strong {
  display: block;
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  margin-bottom: 3px;
}
.auth-info small { color: var(--muted); font-size: .78rem; }

/* — Pavé PIN — */
.form-pin {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.form-pin[hidden] { display: none; }

.pin-libelle {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 20px;
  text-align: center;
}

.pin-points { display: flex; gap: 14px; margin-bottom: 28px; }
.point {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border-fort);
  transition: background .15s, transform .15s, border-color .15s;
}
.point.plein {
  background: var(--gold);
  border-color: var(--gold);
  transform: scale(1.15);
}

.pin-pave {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
}
.touche {
  aspect-ratio: 1.5;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-m);
  font-size: 1.4rem;
  font-weight: 600;
  transition: background .12s, transform .1s;
}
.touche:active { background: var(--panel3); transform: scale(.94); }
.touche-del { font-size: 1.15rem; color: var(--muted); }

.pin-erreur {
  min-height: 22px;
  margin-top: 18px;
  color: var(--danger);
  font-size: .85rem;
  text-align: center;
}

.form-pin.verifie { opacity: .5; pointer-events: none; }
.form-pin.secousse { animation: secousse .42s; }
@keyframes secousse {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.btn-lien {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px;
  margin-top: 10px;
}
.btn-lien:hover { color: var(--text); }

/* ============================================================
   COQUE DE L'APPLICATION
   ============================================================ */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
#app[hidden] { display: none; }

.bandeau {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-haut)) 16px 12px;
  background: linear-gradient(180deg, var(--bg-haut), rgba(6,13,7,.92));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

.bandeau-gauche { flex: 1; min-width: 0; }

.bandeau-titre {
  font-size: .95rem;
  color: var(--gold);
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bandeau-date {
  color: var(--faint);
  font-size: .72rem;
  margin-top: 2px;
  text-transform: capitalize;
}

.badge-joueur {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px 5px 7px;
  max-width: 40vw;
  flex-shrink: 0;
}
.badge-avatar { font-size: 1.2rem; }
.badge-texte { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.badge-nom { font-size: .8rem; font-weight: 700; }
.badge-stats {
  font-size: .64rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.btn-sync {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  flex-shrink: 0;
}
.sync-icone { display: block; font-size: 1rem; }
.sync-icone.actif { animation: rotation 1s linear infinite; color: var(--gold); }
@keyframes rotation { to { transform: rotate(360deg); } }

.banniere-erreur {
  background: rgba(196,92,82,.14);
  border-bottom: 1px solid rgba(196,92,82,.4);
  color: #e8b0a8;
  font-size: .78rem;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.banniere-erreur[hidden] { display: none; }
.banniere-erreur .btn-lien { margin: 0; color: #f0c8c2; }

/* Chantier en cours : information, pas alerte */
.banniere-info {
  background: rgba(127,199,192,.1);
  border-bottom-color: rgba(127,199,192,.35);
  color: #a8d6d1;
}

.contenu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--gap) 16px 0;
  scroll-behavior: smooth;
}

.ecran { display: flex; flex-direction: column; }
.fond-page { height: calc(96px + var(--safe-bas)); flex-shrink: 0; }

/* — Barre d'onglets — */
.onglets {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-bas));
  background: rgba(10,20,9,.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.onglet {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  border-radius: var(--r-m);
  color: var(--faint);
  transition: color .16s, background .16s;
}
.onglet-icone { font-size: 1.18rem; line-height: 1; }
.onglet-texte { font-size: .62rem; font-weight: 700; letter-spacing: .02em; }
.onglet.actif { color: var(--gold); background: rgba(201,168,76,.1); }
.onglet:active { transform: scale(.95); }

/* — Bouton flottant Oracle — */
.oracle-fab {
  position: fixed;
  right: 18px;
  bottom: calc(84px + var(--safe-bas));
  width: 58px; height: 58px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #d9b95c, #a3862f);
  color: #1a1405;
  box-shadow: 0 8px 26px -6px rgba(201,168,76,.55), 0 0 0 1px rgba(255,255,255,.12) inset;
  z-index: 40;
  transition: transform .14s, box-shadow .18s;
}
.oracle-fab[hidden] { display: none; }
.oracle-fab:active { transform: scale(.9); }
.oracle-icone { font-size: 1.9rem; font-weight: 300; line-height: 1; margin-top: -2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .contenu { scroll-behavior: auto; }
}
