* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #111214; color: #eee;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif; touch-action: none;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
canvas#jeu { position: fixed; inset: 0; display: block; }
[hidden] { display: none !important; }
button { font-family: inherit; cursor: pointer; }
:root { --fond: rgba(14,16,20,.82); --pan: rgba(17,19,23,.97); --vert: #7f9b2e; --clair: #c8d66b; --gris: #2a2d33; }

/* ---- HUD */
#hud { display: flex; flex-direction: column; align-items: flex-start; position: fixed; pointer-events: none;
  top: calc(env(safe-area-inset-top) + 8px); left: calc(env(safe-area-inset-left) + 8px); }
#horloge { background: var(--fond); padding: 6px 10px; border-radius: 8px; font-weight: 600; font-size: 15px; }
#lieu { margin-top: 6px; background: var(--fond); padding: 4px 10px; border-radius: 8px; font-size: 13px; }
#lieu:empty { display: none; }
#besoins { position: fixed; top: calc(env(safe-area-inset-top) + 8px); right: calc(env(safe-area-inset-right) + 8px);
  background: var(--fond); padding: 6px 8px; border-radius: 8px; width: 190px; pointer-events: none; }
.bes { display: grid; grid-template-columns: 22px 1fr 46px; align-items: center; gap: 6px; margin: 4px 0; font-size: 12px; }
.barre { height: 8px; background: var(--gris); border-radius: 4px; overflow: hidden; position: relative; }
.barre i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.val { font-size: 11px; color: #bbb; text-align: right; }
#fps { position: fixed; left: calc(env(safe-area-inset-left) + 8px); bottom: 6px; font-size: 11px; color: #9c9; background: var(--fond); padding: 2px 6px; border-radius: 5px; pointer-events: none; }
#zoom { position: fixed; right: calc(env(safe-area-inset-right) + 10px); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 8px; }
#zoom button { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--fond); color: #fff; font-size: 24px; }
#actions { position: fixed; right: calc(env(safe-area-inset-right) + 66px); bottom: calc(env(safe-area-inset-bottom) + 14px);
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#actions button { min-width: 110px; height: 46px; border-radius: 23px; border: 0; padding: 0 16px;
  background: var(--fond); color: #fff; font-size: 16px; font-weight: 600; }
#btnAction, #btnRamasser, #btnBase { background: var(--vert) !important; }
#btnFouiller { position: relative; overflow: hidden; background: var(--vert) !important; }
#progFouiller { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(200,214,107,.55); }
#txtFouiller { position: relative; }
#joy { position: fixed; inset: 0; pointer-events: none; }
#joyBase, #joyKnob { position: absolute; left: 0; top: 0; border-radius: 50%; opacity: 0; transition: opacity .15s; will-change: transform; }
#joyBase { width: 120px; height: 120px; background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.3); }
#joyKnob { width: 54px; height: 54px; background: rgba(255,255,255,.45); }
#joy.actif #joyBase, #joy.actif #joyKnob { opacity: 1; }
#msg { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  max-width: 90vw; pointer-events: none; display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 9; }
#msg div { background: rgba(10,12,16,.88); padding: 7px 14px; border-radius: 8px; font-size: 14px; text-align: center; animation: fondu 5s forwards; }
@keyframes fondu { 0%,80% { opacity: 1 } 100% { opacity: 0 } }
#endu { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 74px); transform: translateX(-50%); width: 200px;
  background: var(--fond); border-radius: 6px; padding: 4px; pointer-events: none; }
#endu .barre { height: 6px; }

/* ---- barre rapide */
.hb { display: flex; gap: 6px; }
#barre { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 10px); transform: translateX(-50%);
  background: var(--fond); padding: 6px; border-radius: 12px; }
.hc { width: 50px; height: 50px; border-radius: 9px; background: #23262c; border: 1px solid #3a3e45; position: relative;
  display: flex; align-items: center; justify-content: center; font-size: 25px; touch-action: none; }
.hc i { position: absolute; left: 4px; top: 1px; font-size: 10px; color: #999; font-style: normal; }
.hc b, .obj b, .case b { position: absolute; right: 4px; bottom: 1px; font-size: 11px; text-shadow: 0 0 3px #000; font-weight: 700; }
.hc.sel { border: 2px solid var(--clair); background: #2e3324; }
.hc.vide { opacity: .45; }
.hc em { position: absolute; right: 3px; top: 2px; font: 700 9px sans-serif; background: #e5c84a; color: #111; border-radius: 4px; padding: 0 3px; }
.hc s, .obj s, .emp s { position: absolute; left: 5px; right: 5px; bottom: 3px; height: 3px; background: #444; border-radius: 2px; }
.hc s u, .obj s u, .emp s u { display: block; height: 100%; background: #e5c84a; border-radius: 2px; }
.dansSac { margin-top: 8px; gap: 4px; } .dansSac .hc { width: 40px; height: 40px; font-size: 20px; }

/* ---- fenetres */
.fenetre { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 0; background: rgba(0,0,0,.5);
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 6px) calc(env(safe-area-inset-bottom) + 6px) calc(env(safe-area-inset-left) + 6px); }
.fenetre.centre { flex-direction: row; align-items: center; justify-content: center; gap: 8px; background: rgba(0,0,0,.62); }
.tabs { display: flex; gap: 4px; flex: none; max-width: 860px; width: 100%; margin: 0 auto; }
.tab { flex: 1; border: 0; background: var(--pan); border-radius: 10px 10px 0 0; padding: 7px 2px; font-size: 13px; font-weight: 700; color: #9aa; border-bottom: 2px solid transparent; }
.tab.on { background: #2e3324; color: #fff; border-bottom-color: var(--clair); }
kbd { font: 10px sans-serif; background: #3a3e45; border-radius: 3px; padding: 0 4px; color: #ccc; margin-left: 3px; }
@media (pointer: coarse) { kbd { display: none; } }
.page { flex: 1; min-height: 0; display: flex; gap: 6px; padding-top: 6px; max-width: 860px; width: 100%; margin: 0 auto; }
.pan { background: var(--pan); border-radius: 12px; padding: 9px 11px; overflow-y: auto; touch-action: pan-y; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
#perso { width: 262px; flex: none; } #panSac { flex: none; } #detail { flex: 1; min-width: 150px; }
.panMenu { width: 300px; text-align: center; } .panCote { width: 260px; }
.sacTete { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 7px; }
.sacTete b { flex: 1; } .sacTete .gris { font-size: 12px; }
.fermer { background: none; border: 0; color: #fff; font-size: 20px; padding: 0 6px; }
.fermer.x { flex: none; width: 38px; background: var(--pan); border-radius: 10px; }
.gris { color: #8a8f98; } .orange { color: #e0a050; } .jaune { color: #e5c84a; } .okv { color: #9ccc65; }
#persoCorps { position: relative; height: 300px; } #persoCorps svg { position: absolute; left: 76px; top: 6px; }
.emp { position: absolute; width: 44px; height: 44px; border-radius: 8px; background: #1c1f24; border: 1px dashed #5b616b; display: flex;
  align-items: center; justify-content: center; font-size: 22px; touch-action: none; }
.emp.plein { border: 1px solid #4a505a; background: #2b3038; } .emp.sel { border: 2px solid var(--clair); }
.emp small { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font-size: 9px; color: #aaa; white-space: nowrap; }
.fant { opacity: .25; filter: grayscale(1); }
.grille2 { position: relative; border: 1px solid #34383f; border-radius: 6px; background-color: #1c1f24;
  background-image: linear-gradient(#34383f 1px, transparent 1px), linear-gradient(90deg, #34383f 1px, transparent 1px);
  background-size: var(--c, 44px) var(--c, 44px); }
.obj { position: absolute; background: #2b3038; border: 1px solid #4a505a; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; touch-action: none; }
.obj.sel { border: 2px solid var(--clair); background: #2e3324; } .pris { opacity: .35; }
.fantome { position: fixed; z-index: 20; font-size: 34px; pointer-events: none; transform: translate(-50%, -50%) rotate(-8deg);
  filter: drop-shadow(0 4px 5px #000); } .fantome.tourne { transform: translate(-50%, -50%) rotate(82deg); }
.liste { display: flex; flex-wrap: wrap; gap: 5px; }
.case { width: 48px; height: 48px; background: #23262c; border: 1px solid #34383f; border-radius: 7px; position: relative;
  font-size: 24px; display: flex; align-items: center; justify-content: center; touch-action: none; }
.poids { margin-top: 7px; font-size: 12px; color: #ccc; }
.pb { height: 7px; background: var(--gris); border-radius: 4px; margin-top: 3px; overflow: hidden; }
.pb i { display: block; height: 100%; background: var(--vert); }
.desc { font-size: 12.5px; line-height: 1.4; color: #ccc; margin-top: 6px; }
.desc h3 { margin: 0 0 4px; font-size: 15px; color: #fff; }
.tag { display: inline-block; background: var(--gris); border-radius: 5px; padding: 2px 6px; margin: 4px 3px 0 0; font-size: 11px; color: #ddd; }
.slot { display: flex; align-items: center; gap: 8px; background: #23262c; border: 2px dashed #6b7280; border-radius: 9px; padding: 6px; margin-top: 8px; }
.slot .cs { width: 40px; height: 40px; flex: none; border-radius: 7px; background: #1a1d22; display: flex; align-items: center; justify-content: center; font-size: 21px; border: 1px solid #4a505a; }
.slot .desc { margin: 0; flex: 1; }
.pan button.vert, .pan button.gr, .pan button.rouge { display: block; width: 100%; margin-top: 6px; padding: 9px; border: 0; border-radius: 8px;
  background: var(--gris); color: #ddd; font-weight: 600; font-size: 14px; }
.pan button.vert { background: var(--vert); color: #fff; font-weight: 700; }
.pan button.rouge { background: #5a2a26; color: #fff; margin-top: 14px; }
.pan button:disabled { opacity: .6; }
.titreMenu { font-size: 22px; font-weight: 700; color: var(--clair); margin: 4px 0 8px; }
.boutons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.boutons button { border: 0; border-radius: 8px; padding: 10px 12px; background: #2c3138; color: #fff; font-size: 14px; }
.ligne { display: grid; grid-template-columns: 24px 1fr 92px; gap: 6px; align-items: center; font-size: 12.5px; margin: 7px 0; }
.ligne .pb { height: 9px; margin: 0; } .ligne span:last-child { text-align: right; color: #bbb; }
.recette { background: #23262c; border: 1px solid #34383f; border-radius: 9px; padding: 8px 10px; margin-top: 8px; font-size: 12.5px; line-height: 1.5; color: #ccc; }
.recette.prete { border-color: var(--clair); } .recette b { color: #fff; font-size: 14px; }
.ami { display: flex; justify-content: space-between; align-items: center; background: #23262c; border-radius: 8px; padding: 7px 10px; margin-top: 6px; color: #9fd0ff; font-size: 14px; }
.ami button { background: none; border: 0; color: #e0a050; font-size: 13px; }
.reg { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 12px; color: #ddd; } .reg input[type=range] { flex: 1; }
#sommeil { position: fixed; inset: 0; background: rgba(5,8,20,.86); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; font-size: 26px; z-index: 6; }
#sommeilInfo { font-size: 15px; color: #bbb; }
#sommeil button { border: 0; border-radius: 10px; padding: 12px 22px; font-size: 17px; background: #2c3138; color: #fff; }
@media (max-width: 700px) and (orientation: portrait) { .page { flex-direction: column; overflow-y: auto; } #perso, #panSac, #detail { width: auto; flex: none; } }

/* ---- ecran de connexion */
#ecranNom { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; touch-action: pan-y;
  background: radial-gradient(circle at 50% 30%, #2b2f26, #0d0e10 70%); z-index: 10; }
.carte { width: min(340px, 90vw); text-align: center; margin: auto; padding: 10px 0; }
.carte h1 { margin: 0; font-size: 32px; letter-spacing: 1px; color: var(--clair); }
.sous { margin: 2px 0 12px; color: #999; } #versionAccueil { color: #666; font-size: 12px; }
.carte input { width: 100%; margin-top: 10px; padding: 11px; font-size: 17px; border-radius: 10px; border: 1px solid #444;
  background: #1b1d21; color: #fff; text-align: center; -webkit-user-select: text; user-select: text; }
.carte button { width: 100%; padding: 12px; font-size: 18px; font-weight: 700; border: 0; border-radius: 10px; background: var(--vert); color: #fff; }
#err { color: #ff6b5b; min-height: 1.2em; margin: 8px 0 4px; }
.aide { color: #777; font-size: 12px; }
.onglets { display: flex; background: #1b1d21; border-radius: 10px; padding: 4px; margin-bottom: 6px; }
.onglets button { flex: 1; margin: 0; padding: 10px 4px; font-size: 15px; font-weight: 600; background: none; color: #999; border-radius: 8px; }
.onglets button.actif { background: var(--vert); color: #fff; }
.carte.creer { width: min(560px, 92vw); }
.carte.creer .champs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.carte.creer #champsCreer { display: contents; }
.carte.creer #nom { grid-column: 1 / 3; }
@media (max-width: 500px) { .carte.creer .champs { grid-template-columns: 1fr; } .carte.creer #nom { grid-column: auto; } }

/* ---- v0.6 */
#btnFeu { background: #b5541c !important; }
#btnFrapper { position: fixed; right: calc(env(safe-area-inset-right) + 16px); bottom: calc(env(safe-area-inset-bottom) + 132px);
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(120,40,30,.75); color: #fff; font-size: 30px; display: none; }
@media (pointer: coarse) { #btnFrapper { display: block; } }
.petit { border: 0; border-radius: 7px; padding: 4px 9px; background: #2c3138; color: #fff; font-size: 12px; }
.hc.choisi { border: 2px solid #9fd0ff; }
/* PC : fenetres plus grandes et centrees */
body.grand .fenetre:not(.centre) { justify-content: center; }
body.grand .tabs, body.grand .page { max-width: 1180px; }
body.grand .page { flex: none; max-height: calc(100vh - 70px); }
body.grand #p_sac .pan { min-height: 460px; }
body.grand .tab { font-size: 16px; padding: 10px 2px; }
body.grand #perso { width: 340px; }
body.grand .emp { width: 57px; height: 57px; font-size: 29px; }
body.grand .emp small { font-size: 11px; top: -15px; }
body.grand .sacTete { font-size: 18px; }
body.grand .desc { font-size: 14.5px; } body.grand .desc h3 { font-size: 18px; }
body.grand .tag { font-size: 12.5px; }
body.grand .pan button.vert, body.grand .pan button.gr, body.grand .pan button.rouge { font-size: 16px; padding: 11px; }
body.grand .dansSac .hc { width: 52px; height: 52px; font-size: 26px; }
body.grand .poids, body.grand .ligne { font-size: 14px; }
body.grand .case { width: 60px; height: 60px; font-size: 30px; }
body.grand .panMenu { width: 380px; }
body.grand #santeBesoins .ligne { margin: 11px 0; }
