/* PÉNURIE — socle visuel : jetons de la DA, typographie, boutons, cartes, feuilles. */
:root {
  --sable: #d8c29a;
  --ocre: #c8742e;
  --rouille: #9c3b22;
  --mesa: #7a4a32;
  --sel: #cfd8d4;
  --ciel: #6fa6a0;
  --goudron: #1a1612;
  --os: #e7dcc3;
  --vert-sec: #7b8a4b;
  --goudron-2: #251e18;
  --goudron-3: #33291f;
  --ok: #8fa24f;
  --font-titre: "Arial Narrow", "Helvetica Neue", Impact, "Franklin Gothic Condensed", sans-serif;
  --font-corps: "American Typewriter", "Courier New", Courier, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --grain-leger: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .15 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--goudron); color: var(--os); }
body {
  font-family: var(--font-corps); font-size: 16px; line-height: 1.35;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
input, textarea { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Fond : photo si elle existe, sinon sable/rouille en dégradés */
#fond {
  position: fixed; inset: 0; z-index: 0;
  background:
    var(--grain),
    url("../assets/art/fond.jpg") 70% 50% / cover no-repeat,
    radial-gradient(120% 70% at 80% 0%, rgba(200,116,46,.55), transparent 60%),
    radial-gradient(90% 60% at 10% 100%, rgba(156,59,34,.45), transparent 65%),
    linear-gradient(170deg, #5a3a28 0%, #3a281c 45%, #1a1612 100%);
  background-blend-mode: soft-light, normal, normal, normal, normal;
}
#fond::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(26,22,18,.35), rgba(26,22,18,.7)); }
#app {
  position: relative; z-index: 1; min-height: 100%; max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding-top: var(--safe-t); padding-bottom: var(--safe-b);
}

/* Typographie */
.titre, h1, h2, h3 { font-family: var(--font-titre); text-transform: uppercase; letter-spacing: .09em; font-weight: 800; margin: 0; }
h1 { font-size: 44px; line-height: 1; }
h2 { font-size: 22px; }
h3 { font-size: 16px; letter-spacing: .12em; }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.pochoir { font-family: var(--font-titre); text-transform: uppercase; letter-spacing: .1em; font-weight: 800; }
.petit { font-size: 13px; }
.discret { opacity: .72; }
.centre { text-align: center; }

/* Boutons : gros, tactiles, tôle et goudron */
.btn {
  appearance: none; border: 0; cursor: pointer; min-height: 52px; padding: 12px 20px; border-radius: 10px;
  font-family: var(--font-titre); text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: 17px;
  background: var(--ocre); color: var(--goudron); box-shadow: 0 4px 0 #6d3a14, inset 0 1px 0 rgba(255,255,255,.35);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; position: relative; overflow: hidden;
  transition: transform .08s, box-shadow .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #6d3a14; }
.btn:disabled { filter: grayscale(.7) brightness(.7); cursor: default; }
.btn.sec { background: var(--os); box-shadow: 0 4px 0 #8c7f63, inset 0 1px 0 #fff8; }
.btn.sombre { background: var(--goudron-3); color: var(--os); box-shadow: 0 4px 0 #0b0907, inset 0 1px 0 rgba(255,255,255,.12); }
.btn.danger { background: var(--rouille); color: var(--os); box-shadow: 0 4px 0 #52200f; }
.btn.plein { width: 100%; }
.btn.petit { min-height: 44px; padding: 8px 14px; font-size: 14px; }
.btn .progres { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(26,22,18,.3); pointer-events: none; }
.btn-icone {
  appearance: none; border: 0; background: rgba(26,22,18,.55); color: var(--os); width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.btn-icone svg { width: 22px; height: 22px; }
.btn-icone[aria-pressed="false"] { opacity: .55; }

/* Papier kraft */
.kraft {
  background: var(--grain-leger), linear-gradient(160deg, #f0e6cc, #e0d3b3);
  color: var(--goudron); border-radius: 8px; box-shadow: 0 3px 0 rgba(0,0,0,.35), 0 6px 14px rgba(0,0,0,.35);
}
.tole {
  background: var(--grain-leger), linear-gradient(145deg, #8b6f5e, #5d4638);
  border: 2px solid #3a2a20; border-radius: 10px; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 3px 0 rgba(0,0,0,.4);
}
.panneau { background: rgba(26,22,18,.82); border: 1px solid rgba(216,194,154,.2); border-radius: 12px; padding: 14px; backdrop-filter: blur(2px); }
.ruban {
  position: absolute; width: 46px; height: 16px; background: rgba(231,220,195,.55); transform: rotate(-6deg);
  box-shadow: 0 1px 2px rgba(0,0,0,.3);
}

/* Images : photo par-dessus un repli sable/rouille. Une image absente ne casse rien. */
.art {
  position: relative; overflow: hidden; background-color: var(--mesa);
  background-image: var(--img, none), var(--repli);
  background-repeat: no-repeat, no-repeat; background-size: cover, cover; background-position: 75% 40%, center;
  --repli:
    repeating-linear-gradient(135deg, rgba(0,0,0,.07) 0 2px, transparent 2px 7px),
    radial-gradient(90% 80% at 80% 20%, rgba(216,194,154,.55), transparent 65%),
    linear-gradient(160deg, var(--t1, #b08a5a), var(--t2, #6b3f2a));
}
.art::before { content: ""; position: absolute; inset: 0; background: var(--grain); opacity: .22; mix-blend-mode: multiply; pointer-events: none; }
.art .etiquette {
  position: absolute; left: 6px; bottom: 4px; right: 6px; font-family: var(--font-titre); font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; font-size: 11px; color: rgba(26,22,18,.7); text-shadow: 0 1px 0 rgba(255,255,255,.25);
}
.art.ok .etiquette { display: none; }
/* teintes de repli par sujet */
.art[data-id="rosa"], .art[data-id="mecano"], .art[data-id="EPAVE"], .art[data-id="PANNE"] { --t1: #c7673a; --t2: #5d2a1c; }
.art[data-id="cole"], .art[data-id="tireur"], .art[data-id="PILLARDS"] { --t1: #b9a279; --t2: #4d3a2a; }
.art[data-id="nia"], .art[data-id="eclaireur"], .art[data-id="ENTREPOT"] { --t1: #a9a76d; --t2: #55502d; }
.art[data-id="amos"], .art[data-id="infirmiere"], .art[data-id="MALADIE"] { --t1: #c9d2cc; --t2: #5f6e69; }
.art[data-id="vera"], .art[data-id="avocat"] { --t1: #d09a58; --t2: #6c3d22; }
.art[data-id="jed"], .art[data-id="sourcier"], .art[data-id="PUITS"] { --t1: #7fb0aa; --t2: #3a5a56; }
.art[data-id="brute"], .art[data-id="CONVOI"], .art[data-id="TEMPETE"] { --t1: #c58a4a; --t2: #4a2e1c; }
.art[data-id="gamin"] { --t1: #e0c690; --t2: #86603a; }
.art.visage { background-size: auto 210%, cover; background-position: 70% 22%, center; border-radius: 50%; }
.art.visage .etiquette { display: none; }

/* Icônes SVG intégrées */
.ico { width: 1.1em; height: 1.1em; vertical-align: -0.16em; display: inline-block; flex: none; fill: currentColor; }
.ico.eau { color: var(--ciel); }
.ico.vivres { color: var(--vert-sec); }
.ico.garde { color: var(--rouille); }
.res { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-weight: 700; }

/* Feuilles (modales), toasts */
#feuilles { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.feuille-fond { position: absolute; inset: 0; background: rgba(10,8,6,.66); pointer-events: auto; animation: fondu .18s both; }
.feuille {
  position: absolute; left: 50%; bottom: 0; width: min(100%, 480px); max-height: 88%; overflow: auto; pointer-events: auto;
  transform: translateX(-50%); background: var(--grain-leger), linear-gradient(170deg, #3a2b20, #231b15);
  border-radius: 16px 16px 0 0; border-top: 3px solid var(--ocre); padding: 18px 16px calc(18px + var(--safe-b));
  animation: monter .22s cubic-bezier(.2,.8,.2,1) both; color: var(--os);
}
.feuille h2 { margin-bottom: 10px; }
.feuille .fermer { position: absolute; right: 8px; top: 8px; }
#toasts { position: fixed; left: 0; right: 0; bottom: calc(92px + var(--safe-b)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  max-width: min(92vw, 440px); padding: 10px 16px; background: var(--os); color: var(--goudron); border-radius: 8px;
  font-weight: 700; box-shadow: 0 4px 0 rgba(0,0,0,.4); animation: toast 3.2s both; text-align: center;
}
.toast.err { background: var(--rouille); color: var(--os); }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 8%, 88% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes fondu { from { opacity: 0; } }
@keyframes monter { from { transform: translate(-50%, 40px); opacity: 0; } }

input.champ {
  width: 100%; min-height: 52px; padding: 10px 14px; border-radius: 8px; border: 2px solid var(--mesa);
  background: var(--os); color: var(--goudron); font: 700 20px var(--font-corps); letter-spacing: .04em;
}
input.champ:focus { outline: 3px solid var(--ocre); outline-offset: 1px; }

.puce { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(231,220,195,.14); }
.puce.ok { background: rgba(143,162,79,.3); }
.puce.alerte { background: rgba(156,59,34,.5); }
.puce.robot { background: rgba(111,166,160,.25); letter-spacing: .08em; font-family: var(--font-titre); text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--ciel); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
