@font-face { font-family: 'Lilita'; src: url('../fonts/lilitaone.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Baloo'; src: url('../fonts/baloo2.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }

:root {
  --creme: #fbf3e2;
  --creme-fonce: #f1e3c8;
  --bois: #8a6a4f;
  --bois-fonce: #5e4634;
  --or: #f4c04e;
  --menthe: #7fcfb4;
  --rose: #f2a3b3;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #e3e6c2; touch-action: none; }
body { font-family: 'Baloo', system-ui, sans-serif; color: var(--bois-fonce); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Haut de l'écran ---------- */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 0; pointer-events: none;
}
.pastille {
  background: var(--creme); border: 3px solid var(--bois); border-radius: 14px; box-shadow: 0 3px 0 var(--bois-fonce);
  font-family: 'Lilita', 'Baloo', sans-serif; font-size: 18px; letter-spacing: .5px; padding: 4px 12px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.pieces { display: flex; align-items: center; gap: 6px; min-width: 84px; justify-content: center; }
.pieces.gagne { animation: gonfle .35s ease-out; }
@keyframes gonfle { 50% { transform: scale(1.15); } }
.piece {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: -3px; flex: none;
  background: radial-gradient(circle at 35% 35%, #ffe9a6, var(--or) 60%, #c98f1d); box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}

.gros-bouton {
  font-family: 'Lilita', sans-serif; font-size: 20px; letter-spacing: .5px;
  background: var(--or); color: var(--bois-fonce); border: 3px solid var(--bois); border-radius: 18px;
  box-shadow: 0 4px 0 var(--bois-fonce); padding: 8px 20px;
}
.gros-bouton:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--bois-fonce); }
.gros-bouton:disabled { background: #e6dccb; color: #a3917e; }
/* Boutons de zoom, sous les pièces */
#zoom { position: fixed; z-index: 5; right: 12px; top: calc(max(10px, env(safe-area-inset-top)) + 54px); display: flex; flex-direction: column; gap: 8px; }
#zoom button {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--creme); border: 3px solid var(--bois); box-shadow: 0 3px 0 var(--bois-fonce);
  font-family: 'Lilita', sans-serif; font-size: 26px; line-height: 1; color: var(--bois-fonce);
}
#zoom button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bois-fonce); }
#zoom button:disabled { opacity: .4; box-shadow: none; }
#ouvrir-boutique { position: fixed; z-index: 5; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); }
#ouvrir-boutique:active { transform: translateX(-50%) translateY(3px); }

/* ---------- Bulles posées sur la scène ---------- */
#bulles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bulle {
  position: absolute; left: 0; top: 0; will-change: transform;
  background: var(--creme); border: 2.5px solid var(--bois); border-radius: 14px; box-shadow: 0 3px 0 rgba(94,70,52,.55);
  padding: 2px 8px 4px; min-width: 40px; text-align: center; line-height: 1;
}
.bulle::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--bois); border-bottom: 0; }
.bulle .icone { font-size: 24px; display: block; padding-top: 2px; }
.bulle.cliquable { pointer-events: auto; cursor: pointer; }
.bulle.cliquable:active { filter: brightness(.95); }
.jauge { display: block; height: 6px; margin-top: 3px; border-radius: 3px; background: #e6dccb; overflow: hidden; }
.jauge b { display: block; height: 100%; border-radius: 3px; background: #7cc576; transition: width .1s linear; }
.jauge.prepa b { background: var(--or); }
.badge {
  position: absolute; right: -9px; top: -9px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: #e5604f; color: #fff; font: 700 13px/20px 'Baloo', sans-serif; font-style: normal; border: 2px solid #fff;
}
/* Bulles des clients : immobiles, repérées par leur couleur (aucune animation, faciles à toucher) */
.bulle.client { padding: 3px 10px 5px; min-width: 50px; }
.bulle.client .icone { font-size: 28px; }
.bulle.client.a-prendre { border-color: #e5604f; border-width: 3px; box-shadow: 0 3px 0 rgba(94,70,52,.55), 0 0 0 4px rgba(229,96,79,.28); }
.bulle.client.attente { border-style: dashed; }
.bulle.client.a-prendre.bloque { border-color: #b9ab9a; box-shadow: 0 3px 0 rgba(94,70,52,.35); filter: grayscale(.7); opacity: .7; }
.bulle.poste { background: #fff8ea; }
.bulle.client.pret { background: #fff3c4; border-color: #c98f1d; border-style: solid; border-width: 3px; box-shadow: 0 3px 0 rgba(94,70,52,.55), 0 0 0 4px rgba(244,192,78,.45); }
.bulle.client.pret.pris { opacity: .5; }
.badge.ok { background: #4f9a6f; }
.bulle.table { background: #e9f6ff; border-color: #5b8db8; }
.bulle.table::after { border-top-color: #5b8db8; }
.bulle.vente { background: #fff; border-color: #e0605a; font-family: 'Lilita', sans-serif; font-size: 15px; padding: 4px 10px; }
.bulle.vente::after { border-top-color: #e0605a; }
.bulle.vente.rachat { background: #fff6dc; border-color: #c98f1d; }
.bulle.vente.rachat::after { border-top-color: #c98f1d; }
.bulle.humeur { background: transparent; border: none; box-shadow: none; font-size: 26px; }
.bulle.humeur::after { display: none; }
.bulle.flottant {
  background: transparent; border: none; box-shadow: none; font-family: 'Lilita', sans-serif; font-size: 22px; color: #fff;
  text-shadow: 0 2px 0 var(--bois-fonce), 0 0 6px rgba(0,0,0,.25); animation: monte 1.2s ease-out forwards;
}
.bulle.flottant::after { display: none; }
.bulle.flottant.gain { color: #ffe27a; }
@keyframes monte { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -50px; } }
.bulle.secoue { animation: refus .45s; }
@keyframes refus { 40% { background: #ffd2cc; border-color: #e5604f; } }

/* ---------- Message ---------- */
#toast {
  position: fixed; z-index: 8; left: 50%; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 70px); transform: translate(-50%, 20px);
  width: max-content; max-width: min(92vw, 420px); text-align: center;
  background: var(--bois-fonce); color: var(--creme); border-radius: 14px; padding: 8px 14px; font-weight: 600; line-height: 1.25;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
#toast.vu { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Panneaux (boutique, terrain) ---------- */
.panneau {
  position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100vw, 520px); max-height: 78vh; display: flex; flex-direction: column;
  background: var(--creme); border: 3px solid var(--bois); border-bottom: 0; border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 24px rgba(60,40,20,.25); padding-bottom: env(safe-area-inset-bottom);
}
.panneau header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; }
.panneau h2 { font-family: 'Lilita', sans-serif; font-weight: 400; font-size: 24px; }
.fermer { width: 36px; height: 36px; border-radius: 50%; background: var(--creme-fonce); border: 2px solid var(--bois); font-size: 16px; }
.panneau nav { display: flex; gap: 6px; padding: 0 16px 8px; }
.panneau nav button { flex: 1; min-width: 0; padding: 6px 2px; border-radius: 12px; background: var(--creme-fonce); border: 2px solid transparent; font-weight: 700; font-size: 15px; white-space: nowrap; }
.panneau nav button.actif { background: #fff; border-color: var(--bois); }
.liste { overflow-y: auto; padding: 4px 12px 12px; display: grid; gap: 8px; }
.article, .option {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  background: #fff; border: 2px solid var(--creme-fonce); border-radius: 16px; padding: 8px 10px;
}
.gros { font-size: 30px; width: 42px; text-align: center; flex: none; }
.texte { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.texte strong { font-size: 17px; line-height: 1.1; }
.texte small { font-size: 13px; color: #8a7462; line-height: 1.2; }
.niveaux { display: flex; gap: 3px; }
.niveaux i { width: 14px; height: 6px; border-radius: 3px; background: var(--creme-fonce); }
.niveaux i.plein { background: var(--menthe); }
.acheter {
  flex: none; display: flex; align-items: center; gap: 5px; font-weight: 800;
  background: var(--or); border: 2px solid var(--bois); border-radius: 12px; padding: 6px 10px; box-shadow: 0 3px 0 var(--bois-fonce);
}
.acheter:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--bois-fonce); }
.acheter:disabled { background: #eee4d3; color: #a3917e; border-color: #c9b9a4; box-shadow: none; }
.fait { flex: none; font-weight: 700; color: #4f9a6f; font-size: 14px; }
.vide { padding: 12px 6px; color: #8a7462; line-height: 1.35; }
.panneau footer { padding: 6px 16px 12px; text-align: center; }
.lien { color: #a3917e; text-decoration: underline; font-size: 14px; }
.fenetre .prix-terrain { padding: 0 16px; font-weight: 700; }
.fenetre .aide { padding: 2px 16px 8px; color: #8a7462; }
.options { overflow-y: auto; padding: 0 12px 14px; display: grid; gap: 8px; }
.option .total { flex: none; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.option .total s { color: #b3a08c; font-weight: 600; font-size: 14px; }
.option:disabled { opacity: .5; }
.option:not(:disabled):active { background: #fff8e6; }

/* ---------- Choix de l'animal ---------- */
#choix {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; text-align: center;
  background: radial-gradient(circle at 50% 0%, #fffaf0, #efe4c9);
  padding: max(20px, env(safe-area-inset-top)) 14px calc(110px + env(safe-area-inset-bottom));
}
#choix h1 { font-family: 'Lilita', sans-serif; font-weight: 400; font-size: clamp(30px, 8vw, 46px); color: var(--bois-fonce); text-shadow: 0 3px 0 #fff; }
#choix p { margin: 4px 0 14px; color: #8a7462; font-size: 17px; }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-width: 760px; margin: 0 auto; }
.carte {
  background: #fff; border: 3px solid var(--creme-fonce); border-radius: 20px; padding: 8px 8px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 4px 0 rgba(94,70,52,.15);
  transition: transform .15s, border-color .15s;
}
.carte img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: #f3e7cf; }
.carte strong { font-family: 'Lilita', sans-serif; font-weight: 400; font-size: 22px; margin-top: 4px; }
.carte small { color: #a3917e; margin-top: -4px; }
.carte .style { font-size: 14px; line-height: 1.2; }
.carte .specialite { font-size: 13px; background: var(--creme); border-radius: 10px; padding: 2px 8px; margin-top: 4px; }
.carte.choisie { border-color: var(--accent); transform: translateY(-4px); box-shadow: 0 6px 0 var(--accent); }
#ouvrir { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); white-space: nowrap; }
#ouvrir:active { transform: translateX(-50%) translateY(3px); }

#chargement {
  position: fixed; z-index: 30; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--creme); border: 3px solid var(--bois); border-radius: 14px; padding: 6px 16px; font-family: 'Lilita', sans-serif; font-size: 20px;
}
