:root {
  --fond: #15110c;
  --panneau: #2a2017;
  --panneau2: #382b1e;
  --bord: #c9a24a;
  --texte: #f3e9d4;
  --texte2: #c9b99c;
  --or: #f2c14e;
  --bleu: #3d7be0;
  --rouge: #d6402f;
  --hud-h: 52px;
  --titre: 'Cinzel', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--fond); color: var(--texte);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
.hidden { display: none !important; }
kbd {
  display: inline-block; padding: 0 5px; border-radius: 4px; font-size: 0.85em;
  background: #00000055; border: 1px solid #ffffff33;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed; inset: 0 0 auto 0; height: calc(var(--hud-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(#2e2318, #1d160f);
  border-bottom: 2px solid var(--camp, var(--bord));
  box-shadow: 0 2px 10px #0008; z-index: 5;
  --camp: var(--bleu);
}
.hud-g { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.hud-c { font-family: var(--titre); font-weight: 900; color: var(--or); white-space: nowrap; }
.hud-d { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: flex-end; }
.camp { display: flex; align-items: center; gap: 7px; font-family: var(--titre); font-weight: 900; font-size: 1.1em; color: var(--camp); white-space: nowrap; }
.camp .pastille { width: 14px; height: 14px; background: var(--camp); border: 2px solid #fff8; }
.or { white-space: nowrap; }
.or small { color: #9fe39a; }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 5px; }
.ico {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid #ffffff22;
  background: #ffffff10; font-size: 18px; line-height: 1;
}
.ico:hover { background: #ffffff22; }
.btn-fin {
  height: 40px; padding: 0 16px; border-radius: 10px; font-weight: 800;
  background: linear-gradient(#f6d27a, #c9962e); color: #2a1a08; border: 1px solid #fff3;
  box-shadow: 0 2px 0 #7a5410; white-space: nowrap;
}
.btn-fin:disabled { filter: grayscale(1) brightness(0.6); }
.btn-fin.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px #f2c14e66, 0 2px 0 #7a5410; transform: scale(1.04); } }

/* ---------- Scène ---------- */
#scene { position: fixed; inset: calc(var(--hud-h) + env(safe-area-inset-top)) 0 0 0; overflow: hidden; }
#jeu { display: block; touch-action: none; cursor: pointer; }

#info {
  position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  min-width: 190px; max-width: 280px; padding: 8px 12px; border-radius: 10px;
  background: #1c150fe6; border: 1px solid #c9a24a66; pointer-events: none;
  font-size: 14px; box-shadow: 0 4px 14px #0008;
}
#info .l { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
#info .l.unite { justify-content: flex-start; margin-top: 4px; padding-top: 4px; border-top: 1px solid #ffffff1a; }
#info .petit { color: var(--texte2); font-size: 13px; justify-content: flex-start; }
.etoiles { color: var(--or); letter-spacing: 1px; }
.etoiles i { color: #ffffff2a; font-style: normal; }

#indice {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 99px; background: #1c150fe0; border: 1px solid #c9a24a55;
  font-size: 13px; color: var(--texte2); pointer-events: none; white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
}

#menuAction {
  position: absolute; display: flex; flex-direction: column; gap: 4px; padding: 6px;
  background: #241b12f2; border: 2px solid var(--bord); border-radius: 12px; box-shadow: 0 6px 18px #000a; z-index: 3;
}
.act {
  min-width: 150px; text-align: left; padding: 9px 12px; border-radius: 8px; border: 0;
  background: #ffffff12; font-weight: 700;
}
.act:hover { background: #ffffff26; }
.act small { font-weight: 400; color: var(--texte2); margin-left: 4px; }
.act.rouge { background: #d6402f55; }
.act.rouge:hover { background: #d6402f88; }
.act.or { background: #f2c14e40; }
.act.or:hover { background: #f2c14e70; }
.act.gris { color: var(--texte2); }

#banniere {
  position: absolute; left: 0; right: 0; top: 38%; padding: 14px 10px; text-align: center; pointer-events: none;
  background: linear-gradient(90deg, transparent, #000c 20%, #000c 80%, transparent);
  border-top: 2px solid var(--camp); border-bottom: 2px solid var(--camp); z-index: 4;
}
#banniere .titre { font-family: var(--titre); font-weight: 900; font-size: clamp(24px, 5vw, 42px); color: var(--camp); text-shadow: 0 2px 0 #000; }
#banniere .sous { color: var(--texte2); margin-top: 2px; }
#banniere.entree { animation: entree 0.35s ease-out both; }
#banniere.sortie { animation: sortie 0.3s ease-in both; }
@keyframes entree { from { transform: translateX(-60px); opacity: 0; } }
@keyframes sortie { to { transform: translateX(60px); opacity: 0; } }

#iaBadge {
  position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 7px 14px; border-radius: 99px; background: #7a1d14e6; border: 1px solid #ff9a8a66;
  font-weight: 700; animation: clign 1.2s ease-in-out infinite; pointer-events: none;
}
@keyframes clign { 50% { opacity: 0.6; } }

/* ---------- Écrans ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: #0b0805cc; backdrop-filter: blur(3px);
}
#ecranAide { z-index: 11; }
#ecranConfirm { z-index: 12; }
#ecranTitre {
  background:
    radial-gradient(ellipse at 20% 40%, #3d7be055, transparent 55%),
    radial-gradient(ellipse at 80% 60%, #d6402f55, transparent 55%),
    #120d08;
}
.panel {
  width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 22px 24px;
  background: linear-gradient(var(--panneau2), var(--panneau));
  border: 2px solid var(--bord); border-radius: 16px; box-shadow: 0 10px 40px #000c, inset 0 0 0 4px #00000033;
  -webkit-user-select: text; user-select: text;
}
.panel.compact { width: min(400px, 100%); text-align: center; }
.panel h2 { font-family: var(--titre); font-weight: 900; color: var(--or); margin: 0 0 12px; font-size: 1.5em; }
.panel h3 { font-family: var(--titre); color: var(--or); margin: 16px 0 6px; font-size: 1.05em; }
.panel ul { margin: 0; padding-left: 20px; }
.panel li { margin: 4px 0; }
.petit { color: var(--texte2); font-size: 0.9em; }
.bleu { color: #7fb0ff; font-weight: 700; }
.astuce { background: #f2c14e1c; border-left: 3px solid var(--or); padding: 8px 12px; border-radius: 6px; }

.titre { text-align: center; width: min(460px, 100%); }
.titre h1 { font-family: var(--titre); font-weight: 900; margin: 0; font-size: clamp(30px, 8vw, 48px); line-height: 1.05; }
.titre h1 .h { color: #6fa3ff; text-shadow: 0 3px 0 #1f4a91; }
.titre h1 .o { color: #ff6b57; text-shadow: 0 3px 0 #7a1d14; }
.titre h1 .contre { display: block; font-size: 0.45em; color: var(--or); letter-spacing: 3px; margin: 4px 0; }
.tagline { color: var(--texte2); margin: 10px 0 20px; letter-spacing: 1px; }

.boutons { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.boutons.ligne { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
.btn {
  padding: 12px 18px; border-radius: 12px; border: 1px solid #ffffff2a; font-weight: 800; font-size: 1.05em;
  box-shadow: 0 3px 0 #0008; transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0008; }
.btn small { display: block; font-weight: 400; font-size: 0.78em; opacity: 0.85; }
.btn-or { background: linear-gradient(#f6d27a, #c9962e); color: #2a1a08; }
.btn-bleu { background: linear-gradient(#5a92ec, #2d5fb5); }
.btn-rouge { background: linear-gradient(#e2604e, #a52a1d); }
.btn-gris { background: linear-gradient(#5a4a38, #3d3226); }

#niveauxListe { display: flex; flex-direction: column; gap: 10px; }
.niveau {
  display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px 14px; border-radius: 12px;
  background: #ffffff0d; border: 1px solid #c9a24a55;
}
.niveau:hover:not(:disabled) { background: #ffffff1c; border-color: var(--bord); }
.niveau:disabled { opacity: 0.5; }
.niveau .num {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--or); color: #2a1a08; font-family: var(--titre); font-weight: 900; font-size: 1.3em;
}
.niveau b { font-family: var(--titre); color: var(--or); }
.niveau small { display: block; color: var(--texte2); margin-top: 2px; }

.prodPanel { width: min(520px, 100%); }
#prodListe { display: flex; flex-direction: column; gap: 8px; }
.prod {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 8px 12px; border-radius: 12px;
  background: #ffffff0d; border: 1px solid #c9a24a44;
}
.prod:hover:not(:disabled) { background: #ffffff1f; border-color: var(--bord); }
.prod:disabled { opacity: 0.4; }
.prod canvas { flex: none; }
.prod-info { flex: 1; min-width: 0; }
.prod-l { display: flex; justify-content: space-between; gap: 8px; }
.prod-l b { font-family: var(--titre); }
.prix { color: var(--or); font-weight: 700; white-space: nowrap; }
.prod-s { font-size: 0.9em; }
.prod small { color: var(--texte2); }

.tableau { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.tableau th, .tableau td { padding: 5px 6px; border-bottom: 1px solid #ffffff14; text-align: center; }
.tableau td:nth-child(2) { text-align: left; }
.tableau .vign { white-space: nowrap; }
.tableau small { color: var(--texte2); }
.stats { margin: 10px 0; }
.stats td:first-child { text-align: left; color: var(--texte2); }
.stats td:nth-child(2) { text-align: center; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  :root { --hud-h: 48px; }
  #hud { gap: 6px; }
  .hud-g { gap: 8px; }
  .camp { font-size: 0.95em; }
  .or small, .hud-c { display: none; }
  .ico { width: 34px; height: 34px; font-size: 16px; }
  #btnZoomMoins, #btnZoomPlus { display: none; }
  .btn-fin { padding: 0 10px; height: 36px; font-size: 0.9em; }
  #info { min-width: 0; max-width: 62vw; font-size: 12px; padding: 6px 9px; }
  #info .petit { font-size: 11px; }
  #indice { font-size: 11px; white-space: normal; text-align: center; }
  .panel { padding: 16px; }
  .act { min-width: 130px; padding: 8px 10px; }
}
@media (max-height: 460px) {
  :root { --hud-h: 44px; }
  .panel { padding: 14px 18px; }
  .titre .tagline { margin: 4px 0 10px; }
  .boutons { gap: 6px; }
  .btn { padding: 8px 14px; }
}
