@font-face { font-family: 'Lilita One'; src: url(fonts/lilita-one.woff2) format('woff2'); font-display: swap; }
/* Une seule ambiance assumée : la nuit des marais de Lerne, couleurs de la série Ludolympe (violet nuit + or). */
  /* Mise en page : un écran d'application — bandeau d'état, arène (canvas) qui prend tout l'espace, barre d'actions au pouce. */
  :root {
    --bg: #160f29; --bg2: #0d0a1c; --panel: #2b2050; --edge: #0e0920; --ink: #f6f0e4; --ink2: #b3a8d3;
    --gold: #ffc93c; --red: #ff4458; --green: #3ddc97; --fire: #ff8a3d; --poison: #b26bff;
    --game: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
    --body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color-scheme: dark;
  }
  * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
  [hidden] { display: none !important; }
  html, body { height: 100%; }
  body { margin: 0; background: var(--bg2); color: var(--ink); font: 15px/1.4 var(--body); overflow: hidden;
    user-select: none; -webkit-user-select: none; touch-action: manipulation; }
  #app { height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto;
    padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-block: 8px; gap: 8px; }

  .bar { display: flex; gap: 8px; }
  .stat { flex: 1; min-width: 0; background: var(--panel); border: 3px solid var(--edge); box-shadow: 0 3px 0 var(--edge);
    border-radius: 14px; padding: 4px 8px 6px; text-align: center; }
  .stat small { display: block; font: 600 11px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
  .stat b { font: 400 22px/1.1 var(--game); font-variant-numeric: tabular-nums; }
  .stat.warn b { color: var(--red); }
  .stat.mult b { color: var(--gold); }
  .stat.mult.hot { animation: pop .25s; }
  @keyframes pop { 50% { transform: scale(1.12); } }
  .title { font: 400 18px var(--game); color: var(--gold); text-align: center; letter-spacing: .02em; min-height: 22px; }

  #arena { flex: 1; min-height: 0; position: relative; border-radius: 18px; overflow: hidden; border: 3px solid var(--edge);
    background: radial-gradient(120% 80% at 50% 100%, #1e4a3a 0%, #142a2a 35%, var(--bg) 75%); }
  canvas { width: 100%; height: 100%; display: block; }
  #msg { position: absolute; left: 10px; right: 10px; top: 10px; margin: 0 auto; width: fit-content; max-width: calc(100% - 20px);
    text-align: center; font: 400 16px/1.25 var(--game); color: var(--ink); background: rgba(14, 9, 32, .82); border: 2px solid var(--edge);
    border-radius: 12px; padding: 7px 12px 8px; pointer-events: none; transition: opacity .3s; text-wrap: balance; }

  .actions { display: flex; gap: 8px; }
  .btn { flex: 1; font: 400 18px var(--game); color: #fff; border: 3px solid var(--edge); box-shadow: 0 4px 0 var(--edge);
    border-radius: 14px; padding: 9px 10px 11px; cursor: pointer; background: linear-gradient(#5b4a8f, #3d2f6e); }
  .btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
  .btn:disabled { opacity: .4; cursor: default; }
  .btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
  .btn.torch { background: linear-gradient(#ffb36b, var(--fire) 50%, #c9541a); }
  .btn.torch.on { outline: 3px solid var(--gold); outline-offset: 2px; animation: pop .6s infinite; }
  .btn.poison { background: linear-gradient(#d39bff, var(--poison) 50%, #7a3bc4); }
  .btn.gold { background: linear-gradient(#ffe07a, var(--gold) 50%, #d18d0c); color: var(--edge); }
  .btn.red { background: linear-gradient(#ff6b6b, #e8364f); }

  /* Fiches (début, butin, fin) */
  #sheet { position: fixed; inset: 0; background: rgba(8, 5, 18, .78); display: grid; place-items: center; z-index: 5;
    padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .card { width: 100%; max-width: 440px; max-height: 100%; overflow: auto; background: var(--panel); border: 3px solid var(--edge);
    box-shadow: 0 6px 0 var(--edge); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
  .card h1 { margin: 0; font: 400 46px/1 var(--game); color: var(--gold); text-align: center; -webkit-text-stroke: 2px var(--edge);
    paint-order: stroke fill; text-shadow: 0 4px 0 var(--edge); text-wrap: balance; }
  .card h2 { margin: 0; font: 400 28px/1.1 var(--game); color: var(--gold); text-align: center; text-wrap: balance; }
  .card p { margin: 0; color: var(--ink); }
  .card .muted { color: var(--ink2); font-size: 14px; text-align: center; }
  .rules { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
  .rules li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; }
  .rules .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 400 15px var(--game);
    color: var(--edge); border: 2px solid var(--edge); }
  .boons { display: grid; gap: 8px; }
  .boon { text-align: left; font: inherit; color: var(--ink); background: #3a2d68; border: 3px solid var(--edge); border-radius: 14px;
    padding: 10px 12px; cursor: pointer; box-shadow: 0 3px 0 var(--edge); }
  .boon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); }
  .boon:focus-visible { outline: 3px solid var(--gold); }
  .boon { display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: start; transition: transform .1s; }
  .boon.sel { outline: 3px solid var(--gold); background: #4a3a82; transform: scale(1.02); }
  .bico { font-size: 30px; line-height: 42px; text-align: center; background: var(--bg); border: 2px solid var(--edge); border-radius: 12px; }
  .btxt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
  .bhead { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
  .bhead b { font: 400 19px var(--game); color: var(--gold); }
  .tag { font: 600 11px var(--body); font-style: normal; letter-spacing: .05em; text-transform: uppercase; border-radius: 999px; padding: 2px 8px; color: var(--edge); }
  .tag.live { background: var(--green); }
  .tag.score { background: var(--gold); }
  .what { font-size: 15px; color: var(--ink); }
  .what b { color: var(--gold); }
  .how { font-size: 13px; color: var(--ink2); }
  #take { position: sticky; bottom: 0; flex: none; }

  /* Bouton « ? » (revoir le tutoriel) */
  .titlerow { display: flex; align-items: center; gap: 8px; }
  .titlerow .title { flex: 1; min-width: 0; }
  .help { flex: none; width: 32px; height: 32px; border-radius: 50%; font: 400 18px var(--game); color: var(--edge); cursor: pointer;
    background: var(--gold); border: 3px solid var(--edge); box-shadow: 0 2px 0 var(--edge); }

  /* Tutoriel en diapositives : défilement horizontal aimanté, une diapo par écran */
  .slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 -18px; }
  .slides::-webkit-scrollbar { display: none; }
  .slide { flex: 0 0 100%; scroll-snap-align: center; padding: 0 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
  .slide .sp { color: var(--ink); font-size: 16px; text-wrap: balance; }
  .slide .sp b { color: var(--gold); }
  .demo { height: 170px; display: grid; place-items: center; background: radial-gradient(circle at 50% 70%, #1e4a3a, var(--bg) 75%);
    border: 2px solid var(--edge); border-radius: 16px; position: relative; overflow: hidden; }
  .stage { position: relative; display: flex; gap: 18px; align-items: center; justify-content: center; width: 100%; height: 100%; }
  .hd { font: 400 30px var(--game); font-style: normal; color: var(--edge); width: 62px; height: 58px; border-radius: 50%; display: grid;
    place-items: center; border: 3px solid var(--edge); box-shadow: 0 4px 0 var(--edge); padding-top: 16px; position: relative; line-height: 1; }
  .hd::before, .hd::after { content: ''; position: absolute; top: 5px; width: 10px; height: 8px; background: #fff8d6; border-radius: 50%;
    box-shadow: inset 2px 0 0 1px var(--edge); }
  .hd::before { left: 14px; } .hd::after { right: 14px; }
  .v1 { background: #7ee08a; } .v2 { background: #3fc7b0; } .v3 { background: #ffb03c; } .v4 { background: #ff6b5b; } .v0 { background: var(--gold); }
  .blade { position: absolute; font-size: 34px; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: 0; }
  .pts { position: absolute; font: 400 22px var(--game); color: var(--gold); -webkit-text-stroke: 4px var(--edge); paint-order: stroke fill; opacity: 0; }
  .flame { position: absolute; font-size: 40px; opacity: 0; }
  .sum { margin: 0; font: 400 18px var(--game); color: var(--ink2); position: absolute; bottom: 8px; left: 0; right: 0; }
  .sum b { color: var(--gold); }
  .chain { gap: 10px; }
  .chain .slot { position: relative; display: grid; place-items: center; }
  .chain .hd { width: 48px; height: 46px; font-size: 24px; }
  .chain .pts { top: -34px; }
  .warns { display: flex; flex-direction: column; gap: 14px; align-items: center; }
  .warn1 { display: flex; flex-direction: column; align-items: center; font: 400 18px var(--game); }
  .broken { font: 400 28px var(--game); color: #ff6b5b; -webkit-text-stroke: 4px var(--edge); paint-order: stroke fill; }
  .warn2 { display: flex; gap: 8px; }
  .pill { font: 400 16px var(--game); background: var(--panel); border: 2px solid var(--edge); color: #ff6b5b; border-radius: 999px; padding: 4px 12px; }
  .slogan.big { font-size: 28px; }
  .dots { display: flex; justify-content: center; gap: 8px; }
  .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink2); opacity: .35; cursor: pointer; }
  .dots i.on { opacity: 1; background: var(--gold); width: 22px; border-radius: 6px; }
  .nav { display: flex; gap: 8px; }
  .nav #skip { flex: .6; }

  /* animations des diapos (seulement sur la diapo visible) */
  .slide.on .idle { animation: bob 1.6s ease-in-out infinite; } .slide.on .d2 { animation-delay: .4s; }
  .slide.on .gone { position: absolute; animation: gone 2.6s infinite; }
  .slide.on .blade { animation: blade 2.6s infinite; }
  .slide.on .sprout { animation: sprout 2.6s infinite; opacity: 0; }
  .slide.on .sprout.l { --dx: -42px; } .slide.on .sprout.r { --dx: 42px; }
  .sprout { position: absolute; }
  .slide.on .dies { animation: dies 2.4s infinite; }
  .slide.on .stage > .pts { animation: ptsUp 2.4s infinite; }
  .slide.on .chain .dies.c2, .slide.on .chain .pts.c2 { animation-delay: .35s; }
  .slide.on .chain .dies.c3, .slide.on .chain .pts.c3 { animation-delay: .7s; }
  .slide.on .chain .dies.c4, .slide.on .chain .pts.c4 { animation-delay: 1.05s; }
  .slide.on .chain .dies { animation: dies 3s infinite; } .slide.on .chain .pts { animation: ptsUp 3s infinite; }
  .slide.on .broken { animation: shake 1.4s infinite; }
  .slide.on .warn2 .pill { animation: blink 1.4s infinite; }
  .slide.on .burns { animation: burns 2.8s infinite; }
  .slide.on .flame { animation: flame 2.8s infinite; }
  .slide.on .pts.late { animation: ptsUp 2.8s infinite; animation-delay: .9s; font-size: 18px; }
  @keyframes bob { 50% { transform: translateY(-8px); } }
  @keyframes gone { 0%, 35% { transform: scale(1); opacity: 1; } 45%, 100% { transform: scale(0); opacity: 0; } }
  @keyframes blade { 0%, 25% { opacity: 0; transform: translate(-90%, -50%) rotate(-30deg); } 35% { opacity: 1; transform: translate(-10%, -50%) rotate(20deg); } 45%, 100% { opacity: 0; } }
  @keyframes sprout { 0%, 42% { opacity: 0; transform: translateX(0) scale(.3); } 60% { opacity: 1; transform: translateX(var(--dx)) scale(1.15); } 70%, 92% { opacity: 1; transform: translateX(var(--dx)) scale(1); } 100% { opacity: 0; transform: translateX(var(--dx)) scale(1); } }
  @keyframes dies { 0%, 25% { transform: none; opacity: 1; } 30% { transform: translateX(-4px); } 35% { transform: translateX(4px); } 60% { transform: translate(30px, -70px) rotate(200deg) scale(.6); opacity: 0; } 100% { opacity: 0; } }
  @keyframes ptsUp { 0%, 30% { opacity: 0; transform: translateY(10px); } 40% { opacity: 1; transform: translateY(-14px); } 75% { opacity: 1; } 90%, 100% { opacity: 0; transform: translateY(-30px); } }
  @keyframes shake { 0%, 60%, 100% { transform: none; } 65% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(6px) rotate(3deg); } 85% { transform: translateX(-3px); } }
  @keyframes blink { 50% { box-shadow: 0 0 0 4px rgba(255, 68, 88, .45); } }
  @keyframes burns { 0%, 30% { filter: none; transform: scale(1); opacity: 1; } 55% { filter: brightness(.25) sepia(1); transform: scale(.9); opacity: 1; } 80%, 100% { opacity: 0; transform: scale(.6) translateY(-20px); } }
  @keyframes flame { 0%, 20% { opacity: 0; transform: translateY(30px) scale(.5); } 35% { opacity: 1; transform: translateY(0) scale(1.2); } 60% { opacity: 1; transform: translateY(-6px) scale(1); } 75%, 100% { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .slide.on * { animation: none !important; opacity: 1 !important; } }
  .label { margin: 4px 0 -4px !important; font: 600 12px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink2); }
  .gear { display: flex; flex-wrap: wrap; gap: 6px; }
  .gear span { background: var(--bg); border: 2px solid var(--edge); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--ink2); }
  .gear b { color: var(--ink); }
  .next { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; font-size: 13px; color: var(--ink2);
    border-top: 2px dashed rgba(255,255,255,.12); padding-top: 10px; }
  .next b { color: var(--ink); }
  .minis { display: inline-flex; gap: 4px; }
  .minis i { font: 400 13px var(--game); font-style: normal; color: var(--edge); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--edge); }
  .recap { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-variant-numeric: tabular-nums; }
  .recap b { font: 400 18px var(--game); text-align: right; }
  .slogan { font: 400 20px var(--game); text-align: center; color: var(--ink); }
  @media (prefers-reduced-motion: reduce) { .btn.torch.on, .stat.mult.hot { animation: none; } }

/* ---------- v2 : gloire à atteindre, régénération, boutique, classement ---------- */
.bar3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.glory { position: relative; overflow: hidden; }
.glory .fill { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--gold); border-radius: 0 3px 0 0; transition: width .4s; }
.glory.done .fill { background: var(--green); }
.glory.done b { color: var(--green); }
.stat b small { display: inline; font: 400 14px var(--game); color: var(--ink2); letter-spacing: 0; text-transform: none; }
.stat.regen b { color: var(--green); }
.stat.regen.soon b { color: var(--red); animation: pop .5s infinite; }
.inv { display: flex; gap: 8px; }

/* bandeau de mise à jour de l'appli */
.update { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 20;
  display: flex; gap: 10px; align-items: center; background: var(--panel); border: 3px solid var(--edge); border-radius: 14px; padding: 8px 10px 8px 14px;
  box-shadow: 0 4px 0 var(--edge); font: 400 15px var(--game); }
.update button { font: 400 15px var(--game); background: var(--gold); color: var(--edge); border: 2px solid var(--edge); border-radius: 10px; padding: 4px 10px; }

/* boutique */
/* la bourse reste collée en haut de la boutique : on voit toujours combien on a */
.purse { display: flex; justify-content: space-between; align-items: center; font: 400 18px var(--game);
  position: sticky; top: -18px; z-index: 2; margin: -18px -18px 0; padding: 12px 18px; background: var(--panel);
  border-bottom: 3px solid var(--edge); box-shadow: 0 4px 10px rgba(8, 5, 18, .5); }
.purse b { color: var(--gold); font-size: 24px; }
.shop { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; background: #3a2d68; border: 3px solid var(--edge);
  border-radius: 14px; padding: 10px; box-shadow: 0 3px 0 var(--edge); }
.item.sold { opacity: .45; }
.item { text-align: left; font: inherit; color: var(--ink); cursor: pointer; width: 100%; transition: transform .1s; }
.item.sel { outline: 3px solid var(--gold); background: #4a3a82; transform: scale(1.02); }
.item:focus-visible { outline: 3px solid var(--gold); }
.item .price { font: 400 17px var(--game); color: var(--edge); background: var(--gold); border: 2px solid var(--edge); border-radius: 10px;
  padding: 6px 10px; white-space: nowrap; }
.item.poor .price { background: #6b6290; color: var(--ink2); }
.item .owned { font-size: 12px; color: var(--green); }
.tag.use { background: #ff8a3d; }
.shopnav { display: flex; flex-direction: column; gap: 8px; position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 10px 18px 18px;
  background: var(--panel); border-top: 3px solid var(--edge); box-shadow: 0 -4px 10px rgba(8, 5, 18, .5); z-index: 2; }
.shopnav .btn { flex: 1; }
.buyrow, .navrow { display: flex; gap: 8px; }

/* classement */
.board { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums; }
.board li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; padding: 5px 8px; background: var(--bg); border-radius: 10px; font-size: 14px; }
.board li.me { outline: 2px solid var(--gold); }
.board b { font: 400 16px var(--game); color: var(--gold); }
.pseudo { display: flex; gap: 8px; }
.pseudo input { flex: 1; min-width: 0; font: 600 16px var(--body); color: var(--ink); background: var(--bg); border: 2px solid var(--edge);
  border-radius: 12px; padding: 8px 10px; }
.modes { display: grid; gap: 8px; }
.modes .btn small { display: block; font: 600 12px var(--body); opacity: .85; }

/* tutoriel : diapos de la v2 */
.gbar { width: 70%; height: 22px; background: var(--bg); border: 3px solid var(--edge); border-radius: 12px; overflow: hidden; position: relative; }
.gbar i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--gold); }
.glabel { font: 400 20px var(--game); color: var(--ink); margin-top: 10px; }
.slide.on .gbar i { animation: gfill 2.6s infinite; }
.slide.on .glabel .ok { animation: okin 2.6s infinite; }
.glabel .ok { color: var(--green); opacity: 0; }
@keyframes gfill { 0% { width: 0; } 60%, 100% { width: 100%; background: var(--green); } }
@keyframes okin { 0%, 58% { opacity: 0; } 65%, 100% { opacity: 1; } }
.rg { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rg .badge { font: 400 15px var(--game); color: var(--edge); background: var(--green); border: 2px solid var(--edge); border-radius: 999px; padding: 2px 10px; }
.slide.on .rg .hd { animation: regrow 2.6s infinite; }
.slide.on .rg .hd::selection { background: none; }
@keyframes regrow { 0%, 45% { box-shadow: 0 4px 0 var(--edge), 0 0 0 0 rgba(61,220,151,.0); } 50% { box-shadow: 0 4px 0 var(--edge), 0 0 0 10px rgba(61,220,151,.5); transform: scale(1.15); } 60%, 100% { transform: scale(1); } }
.coin { font: 400 30px var(--game); color: var(--gold); }

/* rappel : la torche et la flèche sautillent quand les coups manquent */
.btn.nudge { animation: nudge .5s 3; }
@keyframes nudge { 30% { transform: translateY(-6px) scale(1.04); } 60% { transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .btn.nudge { animation: none; } }
