/* ===========================================================
   Fourmilière — palette terre/galerie, typographie de carnet
   naturaliste, textures et ombres teintées plutôt que le
   dégradé amber générique + cercle radial-gradient.
   =========================================================== */

:root {
  --terre-tres-fonce: #1c140d;
  --terre-fonce: #2e2115;
  --terre: #4a3625;
  --terre-clair: #7d6247;
  --sable: #ded0b6;
  --sable-clair: #f1e9d8;
  --ambre: #b97a2e;
  --ambre-clair: #d99a4e;
  --vert-mousse: #6b7a4a;
  --rouille: #8f3f2c;

  --police-titre: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', ui-serif, serif;
  --police-corps: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --police-chiffres: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Roboto Mono', Consolas, monospace;

  --rayon-petit: 4px;
  --rayon-moyen: 10px;
  --rayon-grand: 22px;

  --ombre-fonce: 0 2px 6px rgba(20, 12, 4, 0.35);
  --ombre-relief: 0 5px 0 var(--terre-fonce), 0 9px 14px rgba(20, 12, 4, 0.4);
}

* { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent; /* pas de flash bleu au tap mobile */
  tap-highlight-color: transparent;
}

/* Rien n'est sélectionnable par défaut (jeu à clics rapides, la sélection de
   texte/image gêne plus qu'elle n'aide) — seule la zone d'export de
   sauvegarde doit rester copiable, voir plus bas. */
* {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
}
#zone-export {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
}

body {
  margin: 0;
  font-family: var(--police-corps);
  color: var(--terre-tres-fonce);
  background-color: var(--sable-clair);
  background-image:
    radial-gradient(ellipse at 15% -10%, rgba(185, 122, 46, 0.16), transparent 55%),
    radial-gradient(ellipse at 100% 0%, rgba(74, 54, 37, 0.12), transparent 45%);
  min-height: 100vh;
  position: relative;
}

/* Grain subtil pour casser le plat "vecteur IA" — filtre SVG en data URI, aucune requête réseau. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.cache { display: none !important; }

.lien-evitement {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--terre-tres-fonce);
  color: var(--sable-clair);
  padding: .6rem 1rem;
  z-index: 200;
  border-radius: 0 0 var(--rayon-petit) 0;
}
.lien-evitement:focus { left: 0; }

button {
  font-family: inherit;
}
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ambre);
  outline-offset: 3px;
}
button:focus:not(:focus-visible) { outline: none; }

#barre-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 1rem;
  background: linear-gradient(180deg, var(--terre-tres-fonce), var(--terre-fonce));
  color: var(--sable-clair);
  padding: .85rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--ombre-fonce);
}

.stat { text-align: left; }
.stat.cache { display: none; }
.stat-val {
  display: block;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ambre-clair);
  letter-spacing: .01em;
}
.stat-label { font-size: .68rem; opacity: .8; letter-spacing: .02em; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  position: relative;
  z-index: 2;
}

#zone-clic { text-align: center; padding: 1.75rem 0 2rem; }

#bouton-clic {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6rem;
  user-select: none;
  -webkit-user-select: none;
}

.monticule {
  width: 132px;
  height: 132px;
  border-radius: 46% 54% 55% 45% / 55% 45% 55% 45%;
  background:
    radial-gradient(circle at 32% 28%, var(--ambre-clair) 0%, var(--ambre) 55%, var(--terre) 100%);
  box-shadow: var(--ombre-relief);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
#bouton-clic:hover .monticule {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--terre-fonce), 0 12px 18px rgba(20, 12, 4, 0.45);
}
#bouton-clic:active .monticule {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--terre-fonce), 0 3px 6px rgba(20, 12, 4, 0.4);
}
#emoji-clic { font-size: 2.6rem; filter: drop-shadow(0 2px 1px rgba(0,0,0,.2)); }
#bouton-clic .sous-texte {
  font-family: var(--police-titre);
  font-style: italic;
  font-size: .85rem;
  color: var(--terre);
}
#puissance-clic-texte {
  margin-top: .85rem;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  font-size: .82rem;
  color: var(--terre-clair);
}

#onglets { display: flex; gap: .4rem; margin-bottom: 1.1rem; }
.onglet {
  flex: 1;
  padding: .65rem;
  border: none;
  border-radius: var(--rayon-petit);
  background: transparent;
  color: var(--terre);
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  border-bottom: 2px solid var(--sable);
  transition: color .15s ease, border-color .15s ease;
}
.onglet:hover { color: var(--ambre); }
.onglet.actif { color: var(--terre-tres-fonce); border-bottom-color: var(--ambre); }

.panneau.cache { display: none; }

h2 {
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1.2rem;
  margin: 1.4rem 0 .5rem;
  color: var(--terre-fonce);
}
h2:first-child { margin-top: 0; }

.branche-competences { margin-bottom: 1.4rem; }
.branche-competences h3 {
  font-family: var(--police-titre);
  font-weight: 400;
  font-size: 1rem;
  color: var(--terre);
  margin: 0 0 .5rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--sable);
}
.noeud-competence {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--sable-clair);
  border-left: 3px solid transparent;
  border-radius: var(--rayon-petit) var(--rayon-moyen) var(--rayon-moyen) var(--rayon-petit);
  padding: .6rem .8rem;
  margin-bottom: .45rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.noeud-competence:hover { box-shadow: 0 3px 10px rgba(74, 54, 37, 0.18); transform: translateY(-1px); }
.noeud-competence.verrouille { opacity: .4; pointer-events: none; }
.noeud-competence.possedee { border-left-color: var(--ambre); opacity: .7; cursor: default; pointer-events: none; }
.noeud-competence .nom { font-weight: 700; font-size: .92rem; }
.noeud-competence .description {
  font-size: .78rem;
  color: var(--terre);
  margin-top: .2rem;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
}
.noeud-competence .infos { flex: 1; min-width: 0; }
.noeud-competence button {
  border: none;
  border-radius: var(--rayon-petit);
  padding: .5rem .75rem;
  background: var(--ambre);
  color: var(--sable-clair);
  font-weight: 700;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  align-self: center;
  pointer-events: none;
}
.noeud-competence button:disabled { background: var(--sable); color: var(--terre-clair); }

.carte-batiment, .carte-amelioration {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: var(--sable-clair);
  border-left: 3px solid transparent;
  border-radius: var(--rayon-petit) var(--rayon-moyen) var(--rayon-moyen) var(--rayon-petit);
  padding: .65rem .8rem;
  margin-bottom: .45rem;
  box-shadow: 0 1px 0 rgba(74, 54, 37, 0.12);
  transition: border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.carte-batiment:hover, .carte-amelioration:hover {
  box-shadow: 0 3px 10px rgba(74, 54, 37, 0.18);
  transform: translateY(-1px);
}
.carte-batiment:active, .carte-amelioration:active { transform: translateY(0); }
.carte-batiment.verrouille, .carte-amelioration.verrouille { display: none; }
.carte-batiment.abordable { border-left-color: var(--ambre); }
.carte-amelioration.achetee {
  opacity: .55;
  cursor: default;
  pointer-events: none;
}

.carte-batiment .quantite {
  order: -1;
  align-self: center;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  font-size: .78rem;
  font-weight: 600;
  color: var(--terre-clair);
  background: var(--sable);
  border-radius: 999px;
  padding: .15rem .5rem;
  min-width: 1.6em;
  text-align: center;
}
.carte-batiment.abordable .quantite { color: var(--ambre); background: rgba(185, 122, 46, 0.15); }

.carte-batiment .icone, .carte-amelioration .icone {
  font-size: 1.5rem;
  width: 1.9rem;
  text-align: center;
  padding-top: .1rem;
}
.carte-batiment .infos, .carte-amelioration .infos { flex: 1; min-width: 0; }
.carte-batiment .nom, .carte-amelioration .nom { font-weight: 700; font-size: .95rem; }
.carte-batiment .flaveur { font-size: .74rem; color: var(--terre-clair); font-style: italic; margin-top: .1rem; }
.carte-batiment .prod, .carte-batiment .prod-extra {
  font-size: .74rem;
  color: var(--vert-mousse);
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  margin-top: .2rem;
}
.carte-amelioration .description {
  font-size: .78rem;
  color: var(--terre);
  margin-top: .2rem;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
}
.rendement {
  font-size: .7rem;
  color: var(--ambre);
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  margin-top: .15rem;
}
.rendement.cache { display: none; }

.carte-batiment .quantite {
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  color: var(--terre-clair);
  font-weight: 400;
}

/* Chip de prix : purement informatif, l'interaction se fait sur la carte entière. */
.carte-batiment button, .carte-amelioration button {
  border: none;
  border-radius: var(--rayon-petit);
  padding: .5rem .75rem;
  background: var(--ambre);
  color: var(--sable-clair);
  font-weight: 700;
  font-family: var(--police-chiffres);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
  pointer-events: none;
}
.carte-batiment button:disabled, .carte-amelioration button:disabled {
  background: var(--sable);
  color: var(--terre-clair);
  cursor: not-allowed;
}

.explication { font-size: .85rem; color: var(--terre-clair); max-width: 42em; }

.selecteur-langue { display: flex; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.selecteur-langue button {
  border: 1px solid var(--sable);
  border-radius: var(--rayon-petit);
  background: var(--sable-clair);
  color: var(--terre);
  padding: .5rem .9rem;
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.selecteur-langue button:hover { border-color: var(--ambre-clair); }
.selecteur-langue button.actif { background: var(--terre-tres-fonce); color: var(--sable-clair); border-color: var(--terre-tres-fonce); }

#panneau-reglages button:not(.selecteur-langue button) {
  display: block;
  width: 100%;
  margin-bottom: .6rem;
  padding: .7rem;
  border: none;
  border-radius: var(--rayon-petit);
  background: var(--ambre);
  color: var(--sable-clair);
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease;
}
#panneau-reglages button:not(.selecteur-langue button):hover { background: var(--ambre-clair); }
#panneau-reglages button.danger { background: var(--rouille); }
#panneau-reglages button.danger:hover { background: #a8503a; }
#zone-export {
  width: 100%;
  height: 90px;
  margin-top: .5rem;
  font-family: var(--police-chiffres);
  font-size: .75rem;
  border: 1px solid var(--sable);
  border-radius: var(--rayon-petit);
  padding: .5rem;
}
#zone-export.cache { display: none; }

.modale.cache { display: none; }
.modale {
  position: fixed; inset: 0;
  background: rgba(20, 12, 4, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modale-contenu {
  background: var(--sable-clair);
  border-radius: var(--rayon-grand) var(--rayon-petit) var(--rayon-grand) var(--rayon-petit);
  padding: 1.6rem;
  max-width: 420px;
  text-align: left;
  box-shadow: 0 20px 40px rgba(20, 12, 4, 0.4);
}
.modale-contenu h2 { margin-top: 0; }
.modale-contenu button {
  margin-top: 1.1rem;
  border: none;
  border-radius: var(--rayon-petit);
  padding: .6rem 1.2rem;
  background: var(--ambre);
  color: var(--sable-clair);
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease;
}
.modale-contenu button:hover { background: var(--ambre-clair); }

@media (max-width: 420px) {
  .monticule { width: 108px; height: 108px; }
  #emoji-clic { font-size: 2.1rem; }
}
