/* EMPIRE BANGER : LE JEU DU CHAOS — interface */
@font-face { font-family: 'Luckiest Guy'; src: url('../fonts/luckiest-guy.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('../fonts/baloo2-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Baloo 2'; src: url('../fonts/baloo2-800.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
    --encre: #1b1430; --jaune: #ffd23f; --rose: #ff3d8b; --cyan: #2de2e6; --vert: #3ddc84; --violet: #7a4fd6; --orange: #ff7a00;
    --creme: #fff8e8; --gris: #b8b2c8; --taille-tact: 1;
    --sur: env(safe-area-inset-top, 0px); --sous: env(safe-area-inset-bottom, 0px); --sg: env(safe-area-inset-left, 0px); --sd: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1659; color: var(--encre); font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 700; }
body { overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
canvas#jeu { position: fixed; inset: 0; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ---------- logo ---------- */
.logo { display: flex; flex-direction: column; align-items: flex-start; line-height: .85; font-family: 'Luckiest Guy', system-ui; filter: drop-shadow(0 6px 0 var(--encre)); transform: rotate(-3deg); }
.logo-1 { font-size: clamp(36px, 7vw, 76px); color: #fff; -webkit-text-stroke: 3px var(--encre); paint-order: stroke fill; }
.logo-2 { font-size: clamp(56px, 12vw, 132px); color: var(--jaune); -webkit-text-stroke: 4px var(--encre); paint-order: stroke fill; }
.logo-3 { font-size: clamp(16px, 2.6vw, 28px); background: var(--rose); color: #fff; padding: 6px 14px 2px; border: 3px solid var(--encre); border-radius: 10px; margin-top: 6px; }
.logo.danse { animation: danse 1.2s ease-in-out infinite; }
@keyframes danse { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(4deg) scale(1.04); } }
body.photosensible .logo.danse { animation: none; }

/* ---------- chargement ---------- */
.chargement { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: radial-gradient(circle at 50% 40%, #7a2a8c, #2a1659 70%); z-index: 50; color: #fff; }
.chargement .logo { align-items: center; }
.chargement .barre { width: min(420px, 80vw); height: 22px; border: 4px solid var(--encre); border-radius: 12px; background: #fff; overflow: hidden; }
.chargement .barre div { height: 100%; width: 0; background: var(--jaune); transition: width .2s; }
.erreur { position: fixed; inset: 20px; z-index: 99; background: #fff; border: 4px solid var(--encre); border-radius: 16px; padding: 20px; }

/* ---------- boutons « cube » ---------- */
.cube { --c: #fff; --o: var(--encre); font: inherit; font-family: 'Luckiest Guy', system-ui; font-size: 20px; letter-spacing: .5px; color: var(--encre);
    background: var(--c); border: 4px solid var(--encre); border-radius: 14px; padding: 12px 18px 8px; cursor: pointer;
    box-shadow: 0 6px 0 var(--o); transform: translateY(0); transition: transform .06s, box-shadow .06s; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; text-align: center; min-height: 48px; }
.cube small { font-family: 'Baloo 2', system-ui; font-size: 13px; font-weight: 800; letter-spacing: 0; opacity: .8; }
.cube:active:not(:disabled), .cube.appui { transform: translateY(5px); box-shadow: 0 1px 0 var(--o); }
.cube:disabled { opacity: .45; cursor: not-allowed; }
.cube.sans-clic { cursor: default; pointer-events: none; }
.cube.jaune { --c: var(--jaune); } .cube.rose { --c: var(--rose); color: #fff; } .cube.cyan { --c: var(--cyan); } .cube.vert { --c: var(--vert); }
.cube.violet { --c: var(--violet); color: #fff; } .cube.orange { --c: var(--orange); color: #fff; } .cube.rouge { --c: #e5322d; color: #fff; } .cube.gris { --c: var(--gris); } .cube.blanc { --c: #fff; }
.cube.petit { font-size: 15px; padding: 8px 12px 5px; min-height: 40px; border-width: 3px; box-shadow: 0 4px 0 var(--o); border-radius: 11px; }
.cube.petit:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--o); }
.cube.carre { width: 44px; padding: 6px 0 3px; }
.cube.gros { font-size: 26px; padding: 14px 26px 10px; }
.cube.enorme { font-size: clamp(34px, 6vw, 56px); padding: 16px 40px 10px; border-width: 5px; box-shadow: 0 9px 0 var(--o); border-radius: 20px; }
.cube.enorme small { font-size: 15px; }
.rangee { display: flex; gap: 12px; justify-content: center; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.rangee.col { flex-direction: column; align-items: stretch; }

/* ---------- écrans ---------- */
.ecrans { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(12px + var(--sur)) calc(16px + var(--sd)) calc(90px + var(--sous)) calc(16px + var(--sg)); z-index: 10;
    background: linear-gradient(180deg, rgba(27,20,48,.35), rgba(27,20,48,.75)); color: #fff; }
.ecrans.centre { display: flex; align-items: center; justify-content: center; }
.ecrans.menu-ecran { background: linear-gradient(90deg, rgba(27,20,48,.7), rgba(27,20,48,.15) 70%); }
.barre-haut { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.pieces-total, .hud-pieces { display: inline-flex; align-items: center; gap: 6px; background: var(--encre); color: var(--jaune); border: 3px solid var(--jaune); border-radius: 30px; padding: 4px 14px 2px; font-family: 'Luckiest Guy', system-ui; font-size: 20px; }
.piece-ico { width: 18px; height: 18px; border-radius: 50%; background: var(--jaune); border: 3px solid #ff9f1c; display: inline-block; }
.titre-ecran { font-family: 'Luckiest Guy', system-ui; font-size: clamp(28px, 5vw, 44px); margin: 6px 0 4px; color: var(--jaune); -webkit-text-stroke: 2px var(--encre); paint-order: stroke fill; text-shadow: 0 4px 0 var(--encre); }
.sous-titre { margin: 0 0 14px; opacity: .9; }
.panneau-ui { background: var(--creme); color: var(--encre); border: 5px solid var(--encre); border-radius: 22px; padding: 18px 22px; max-width: 760px; margin: 10px auto; box-shadow: 0 10px 0 var(--encre); }
.panneau-ui.etroit { max-width: 520px; }
.panneau-ui h2 { font-family: 'Luckiest Guy', system-ui; font-size: 32px; margin: 0 0 8px; color: var(--rose); }
.panneau-ui h3 { margin: 16px 0 6px; }
.panneau-ui fieldset { border: 3px solid var(--encre); border-radius: 14px; margin: 12px 0; padding: 8px 14px; }
.panneau-ui legend { font-family: 'Luckiest Guy', system-ui; padding: 0 6px; }
.panneau-ui label { display: flex; gap: 10px; align-items: center; padding: 6px 0; cursor: pointer; }
.panneau-ui input[type=radio], .panneau-ui input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--rose); }
.panneau-ui textarea, .panneau-ui input.lien, .ed-haut input, .ed-haut select, .ed-bas input, select { font: inherit; border: 3px solid var(--encre); border-radius: 10px; padding: 8px 10px; width: 100%; background: #fff; color: var(--encre); user-select: text; -webkit-user-select: text; }
.panneau-ui .ligne { justify-content: space-between; }
.panneau-ui .ligne input[type=range] { flex: 1; max-width: 260px; accent-color: var(--rose); }
.panneau-ui .ligne select { width: auto; }
.petit-texte { font-size: 13px; opacity: .75; }
.accroche { font-family: 'Luckiest Guy', system-ui; font-size: 20px; }
.top { padding-left: 22px; }

/* menu */
.menu { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "logo perso" "jouer perso" "grille grille"; gap: 14px 20px; max-width: 980px; margin: 0 auto; align-items: center; }
.menu .logo { grid-area: logo; }
.menu .cube.enorme { grid-area: jouer; justify-self: start; }
.menu-perso { grid-area: perso; align-self: end; }
.menu-perso canvas { width: clamp(90px, 16vw, 170px); height: auto; filter: drop-shadow(0 6px 0 var(--encre)); }
.grille-menu { grid-area: grille; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grille-menu .cube { min-height: 74px; font-size: 18px; }

/* grilles */
.grille-niveaux { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.carte-niveau { align-items: flex-start; text-align: left; min-height: 130px; padding: 12px 14px 10px; position: relative; }
.carte-niveau .num { font-size: 34px; color: var(--rose); line-height: 1; }
.carte-niveau .nom { font-size: 16px; line-height: 1.1; }
.carte-niveau .info { font-family: 'Baloo 2'; font-size: 13px; margin-top: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.carte-niveau.fini { --c: #e7fbe9; }
.carte-niveau.ferme { --c: #d9d4e6; opacity: .85; }
.carte-niveau.secret { --c: #2b2140; color: var(--jaune); }
.etoile-ok { color: #ff9f1c; font-size: 20px; }
.med { font-family: 'Luckiest Guy'; font-size: 12px; border: 2px solid var(--encre); border-radius: 8px; padding: 2px 6px 0; }
.med.or { background: var(--jaune); } .med.argent { background: #dfe6f0; } .med.bronze { background: #e0a96d; }
.grille-persos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.carte-perso, .carte-objet, .carte-succes { background: var(--creme); color: var(--encre); border: 4px solid var(--encre); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; box-shadow: 0 6px 0 var(--encre); }
.carte-perso canvas { width: 110px; height: 110px; }
.carte-perso b { font-family: 'Luckiest Guy'; font-size: 20px; }
.carte-perso i { font-size: 13px; opacity: .7; }
.carte-perso .capa { font-size: 13px; min-height: 52px; }
.carte-perso.choisi, .carte-objet.choisi { background: #fff4c2; }
.carte-perso.ferme canvas { filter: grayscale(.85) brightness(.8); }
.verrou { font-size: 13px; background: var(--encre); color: #fff; border-radius: 10px; padding: 6px 10px; }
.onglets { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.grille-objets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.carte-objet canvas { width: 110px; height: 130px; }
.apercu-txt { width: 110px; height: 80px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--encre); color: var(--jaune); font-family: 'Luckiest Guy'; }
.apercu-txt.etincelles { background: radial-gradient(circle, #ffd23f 10%, var(--encre) 60%); } .apercu-txt.bulles { background: radial-gradient(circle at 30% 30%, #bfefff 12%, var(--encre) 40%); }
.apercu-txt.notes { color: var(--rose); } .apercu-txt.arcenciel { background: linear-gradient(90deg, #ff3d8b, #ffd23f, #3ddc84, #2de2e6, #7a4fd6); color: var(--encre); }
.carte-objet.pack ul { text-align: left; font-size: 13px; padding-left: 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stats div { background: var(--creme); color: var(--encre); border: 4px solid var(--encre); border-radius: 14px; padding: 8px; text-align: center; }
.stats b { display: block; font-family: 'Luckiest Guy'; font-size: 24px; color: var(--rose); }
.grille-succes { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.carte-succes { align-items: flex-start; text-align: left; opacity: .55; }
.carte-succes.ok { opacity: 1; }
.carte-succes i { font-size: 12px; } .carte-succes span { font-size: 13px; }
.carte-succes.rare.ok { background: #dff6ff; } .carte-succes.epique.ok { background: #f0e2ff; } .carte-succes.legendaire.ok { background: #fff1b8; }
.ligne-touche { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.ligne-touche span { flex: 1; } .ligne-touche code { background: #fff; border: 2px solid var(--encre); border-radius: 8px; padding: 2px 8px; }

/* ---------- HUD ---------- */
.hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.hud-g, .hud-d { position: absolute; top: calc(10px + var(--sur)); display: flex; gap: 8px; align-items: center; pointer-events: auto; flex-wrap: wrap; }
.hud-g { left: calc(12px + var(--sg)); } .hud-d { right: calc(12px + var(--sd)); }
.hud-niveau, .hud-temps, .hud-morts, .hud-mut, .hud-replay { background: var(--encre); color: #fff; border-radius: 12px; padding: 5px 12px 2px; font-family: 'Luckiest Guy'; font-size: 18px; border: 3px solid #fff; }
.hud-temps { color: var(--jaune); min-width: 86px; text-align: center; font-variant-numeric: tabular-nums; }
.hud-mut { background: var(--rose); } .hud-replay { background: #e5322d; }
.hud-etoile { font-size: 30px; color: var(--jaune); -webkit-text-stroke: 2px var(--encre); }
body.rec .hud-d .cube.rouge { outline: 4px solid #fff; }
.banniere-mut { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); background: var(--jaune); border: 4px solid var(--encre); border-radius: 16px; padding: 8px 22px 4px; font-family: 'Luckiest Guy'; font-size: 30px; text-align: center; box-shadow: 0 6px 0 var(--encre); }
.banniere-mut small { display: block; font-family: 'Baloo 2'; font-size: 15px; }
.banniere-mut.bientot { background: #fff; font-size: 22px; }

/* fin de partie */
.fin { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: auto; background: rgba(27,20,48,.35); padding: 16px; overflow-y: auto; }
.panneau-fin { position: relative; overflow: hidden; background: var(--creme); border: 5px solid var(--encre); border-radius: 24px; padding: 18px 22px; max-width: 620px; width: 100%; text-align: center; box-shadow: 0 10px 0 var(--encre); animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }
body.photosensible .panneau-fin { animation: none; }
.panneau-fin h2 { font-family: 'Luckiest Guy'; font-size: clamp(26px, 5vw, 40px); margin: 4px 0; color: var(--rose); }
.panneau-fin.defaite { max-width: 520px; }
.presque { font-size: 22px; } .presque b { color: var(--rose); font-family: 'Luckiest Guy'; font-size: 30px; }
.titre-victoire { font-size: clamp(40px, 8vw, 70px) !important; color: var(--jaune) !important; -webkit-text-stroke: 3px var(--encre); paint-order: stroke fill; text-shadow: 0 6px 0 var(--encre); position: relative; }
.panneau-fin .med { font-size: 22px; padding: 6px 14px 2px; position: relative; }
.rayons { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg, rgba(255,210,63,.18) 0 10deg, transparent 10deg 20deg); animation: tourne 18s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
body.photosensible .rayons { animation: none; }
.stats-fin { display: flex; justify-content: center; gap: 12px; margin: 10px 0; position: relative; }
.stats-fin div { background: #fff; border: 3px solid var(--encre); border-radius: 14px; padding: 6px 14px; }
.stats-fin b { display: block; font-family: 'Luckiest Guy'; font-size: 26px; } .stats-fin em { color: var(--rose); font-style: normal; }
.debloque { font-family: 'Luckiest Guy'; color: var(--violet); position: relative; }
.panneau-fin .rangee { position: relative; }

/* ---------- tactile ---------- */
.tactile { position: fixed; inset: auto 0 0 0; height: 0; z-index: 6; pointer-events: none; }
.tact-gauche, .tact-droite { position: fixed; bottom: calc(14px + var(--sous)); display: flex; gap: calc(14px * var(--taille-tact)); align-items: flex-end; pointer-events: auto; touch-action: none; }
.tact-gauche { left: calc(14px + var(--sg)); } .tact-droite { right: calc(14px + var(--sd)); }
.tbtn { width: calc(84px * var(--taille-tact)); height: calc(84px * var(--taille-tact)); border-radius: 50%; border: 4px solid var(--encre); background: rgba(255,255,255,.82); font-family: 'Luckiest Guy'; font-size: calc(30px * var(--taille-tact)); color: var(--encre); box-shadow: 0 5px 0 var(--encre); touch-action: none; padding: 0; }
.tbtn.saut { width: calc(112px * var(--taille-tact)); height: calc(112px * var(--taille-tact)); background: rgba(255,210,63,.9); font-size: calc(24px * var(--taille-tact)); }
.tbtn.action { background: rgba(45,226,230,.85); margin-bottom: calc(60px * var(--taille-tact)); }
.tbtn.petit { width: calc(56px * var(--taille-tact)); height: calc(56px * var(--taille-tact)); font-size: calc(20px * var(--taille-tact)); }
.tact-lean { display: none; flex-direction: column; gap: 8px; }
body.en-vehicule .tact-lean { display: flex; }
body.en-replay .tactile { display: none; }

/* ---------- pubs ---------- */
.pub-banniere { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(6px + var(--sous)); width: min(728px, calc(100% - 24px)); height: 64px; z-index: 11; background: rgba(255,255,255,.9); border: 3px dashed var(--encre); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #555; overflow: hidden; }
body.en-jeu .pub-banniere, body.en-editeur .pub-banniere { display: none !important; }
.pub-test { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pub-test-boite { background: #fff; border: 5px solid var(--encre); border-radius: 18px; max-width: 520px; width: 100%; padding: 16px; text-align: center; }
.pub-test-etiquette { background: var(--encre); color: var(--jaune); border-radius: 8px; padding: 4px; font-size: 13px; }
.pub-test-corps { padding: 40px 10px; font-size: 18px; }
.pub-test-bas { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* ---------- toasts et modales ---------- */
.toasts { position: fixed; top: calc(70px + var(--sur)); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(460px, 90vw); }
.toast { background: var(--encre); color: #fff; border: 3px solid var(--jaune); border-radius: 14px; padding: 10px 16px 6px; text-align: center; transition: opacity .5s, transform .5s; }
.toast.part { opacity: 0; transform: translateY(-10px); }
.toast.succes { background: var(--jaune); color: var(--encre); border-color: var(--encre); }
.toast.succes.epique { background: #e4ccff; } .toast.succes.legendaire { background: linear-gradient(90deg, #ffd23f, #ff9f1c); }
.modale { position: fixed; inset: 0; z-index: 40; background: rgba(27,20,48,.7); display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.apercu-carte { width: 100%; max-width: 360px; border: 4px solid var(--encre); border-radius: 14px; display: block; margin: 0 auto 10px; }
.rangee.wrap { flex-wrap: wrap; }

/* ---------- éditeur ---------- */
.ecrans.editeur-ecran { background: none; pointer-events: none; padding: 0; overflow: hidden; }
.ed-haut, .ed-bas { pointer-events: auto; position: fixed; left: 0; right: 0; background: rgba(27,20,48,.88); padding: 8px calc(10px + var(--sd)) 8px calc(10px + var(--sg)); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ed-haut { top: 0; padding-top: calc(8px + var(--sur)); }
.ed-haut input { width: 180px; padding: 6px 8px; } .ed-haut select { width: auto; padding: 6px 8px; }
.ed-bas { bottom: 0; flex-direction: column; align-items: stretch; padding-bottom: calc(8px + var(--sous)); }
.ed-groupes, .ed-outils { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; }
.ed-outils .cube { flex: 0 0 auto; }
.ed-aide { color: #fff; font-size: 13px; opacity: .8; }

/* ---------- écrans étroits / portrait ---------- */
@media (max-width: 760px) {
    .grille-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .menu { grid-template-columns: 1fr; grid-template-areas: "logo" "jouer" "grille"; }
    .menu-perso { display: none; }
    .menu .cube.enorme { justify-self: stretch; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hud-niveau { display: none; }
    .grille-persos { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
@media (max-height: 500px) {
    .menu { grid-template-columns: auto 1fr; grid-template-areas: "logo jouer" "grille grille"; gap: 8px 16px; }
    .menu-perso { display: none; }
    .grille-menu .cube { min-height: 54px; font-size: 15px; padding: 6px 8px 4px; }
    .logo-2 { font-size: 56px; } .logo-1 { font-size: 30px; }
    .panneau-fin { padding: 10px 14px; } .panneau-fin .rangee { margin: 6px 0; }
    .titre-victoire { font-size: 36px !important; }
    .stats-fin b { font-size: 20px; }
}
.portrait-avis { display: none; }
body.portrait.en-jeu.tactile::after { content: 'Tourne ton téléphone pour mieux jouer ↻'; position: fixed; top: calc(60px + var(--sur)); left: 50%; transform: translateX(-50%); background: var(--jaune); border: 3px solid var(--encre); border-radius: 12px; padding: 6px 12px 3px; z-index: 7; font-size: 14px; pointer-events: none; }
body.photosensible * { transition: none !important; }
/* défaite : le panneau descend pour laisser voir le ragdoll */
.fin.en-bas { align-items: flex-end; background: none; padding-bottom: calc(14px + var(--sous)); }
.fin.en-bas .panneau-fin { max-width: 640px; padding: 10px 16px; }
.fin.en-bas .panneau-fin h2 { font-size: clamp(20px, 3.6vw, 30px); }
.fin.en-bas .presque { margin: 4px 0; }
.fin.en-bas .rangee { margin: 6px 0; gap: 8px; }
