/* Poké-Donjon : stats. Style du jeu (fenêtres PMDO, police du jeu, texte contouré), mobile d'abord.
   Toutes les images viennent des assets du jeu : /ui (fenêtres, cartes, icônes) et /sprites (Pokémon). */
/* La police du jeu dessine un petit trait dans ses espaces (même souci réglé dans le jeu) : les espaces
   (normale, insécable, fines U+2000-200B, U+202F, U+205F) ne sont jamais pris dans cette police. */
@font-face { font-family: 'PMD'; src: url('/ui/pkmndp.ttf') format('truetype'); font-display: swap;
  unicode-range: U+0021-009F, U+00A1-1FFF, U+200C-202E, U+2030-205E, U+2060-FFFF; }
@font-face { font-family: 'PMD'; src: url('/ui/pkmndpb.ttf') format('truetype'); font-weight: bold; font-display: swap;
  unicode-range: U+0021-009F, U+00A1-1FFF, U+200C-202E, U+2030-205E, U+2060-FFFF; }
:root {
  --nuit: #0d1026;
  --fen: rgba(26, 31, 58, 0.95);
  --case: #22284a;
  --bord: #3a4275;
  --trait: #2b3260;
  --blanc: #f8f8f8;
  --or: #ffe066;
  --cyan: #9fe8ff;
  --orange: #ff9b3d;
  --rouge: #ff5d5d;
  --vert: #4ee36b;
  --bleu: #5ec8ff;
  --gris: #a9b0d6;
  --contour: #0a0c1c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--nuit); }
body {
  margin: 0; background: var(--nuit); color: var(--blanc);
  font: 20px/1.2 'PMD', 'Trebuchet MS', sans-serif;
  -webkit-font-smoothing: none;
  text-shadow: 2px 0 var(--contour), -2px 0 var(--contour), 0 2px var(--contour), 0 -2px var(--contour),
    2px 2px var(--contour), -2px -2px var(--contour), 2px -2px var(--contour), -2px 2px var(--contour);
}
img, .px { image-rendering: pixelated; }
a { color: inherit; text-decoration: none; }
a:hover .pseudo, a.lien:hover { color: var(--or); }
.lien { color: var(--cyan); }
b, strong { font-weight: bold; }
.page { max-width: 980px; margin: 0 auto; padding: 0 0 40px; }
.or { color: var(--or); } .cyan { color: var(--cyan); } .orange { color: var(--orange); } .rouge { color: var(--rouge); }
.vert { color: var(--vert); } .doux { color: var(--gris); }
.petit { font-size: 17px; }
.nombre { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 2px; }

/* Fenêtres PMDO (découpe 9 cases, agrandie) */
.fen, .carte {
  border: 18px solid transparent;
  border-image: url('/ui/cadre-bleu.png') 8 / 18px / 0 stretch;
  image-rendering: pixelated;
  background: var(--fen) padding-box;
  padding: 2px 4px;
  margin: 0 10px 10px;
  min-width: 0;
}
.fen.vert { border-image-source: url('/ui/cadre-vert.png'); }
.fen.rose { border-image-source: url('/ui/cadre-rose.png'); }
.fen.epais { border-image-source: url('/ui/cadre-bleu-epais.png'); }
.fen.vert.epais { border-image-source: url('/ui/cadre-vert-epais.png'); }
.fen.rose.epais { border-image-source: url('/ui/cadre-rose-epais.png'); }
h2, .titre { margin: 0 0 6px; font-size: 24px; color: var(--or); font-weight: bold; display: flex; align-items: center; gap: 8px; }
h2 img { width: 30px; height: 30px; }
h2 .doux { font-size: 18px; font-weight: normal; }

/* En-tête : carte du Camp */
.entete {
  height: 150px; position: relative; display: flex; flex-direction: column; justify-content: flex-end;
  background: url('/ui/camp.png') -110px -180px / 828px auto no-repeat; image-rendering: pixelated;
  padding: 0 16px 12px; margin-bottom: 4px;
}
.entete::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 30%, #0d1026ee); }
.entete > * { position: relative; z-index: 1; }
.entete h1 { margin: 0; font-size: 34px; color: var(--or); }
.entete .sous { color: var(--cyan); font-size: 19px; }
.entete .deco { position: absolute; right: 22px; top: 52px; width: 48px; height: 48px; z-index: 1; }
.entete.regie { background-position: -300px -40px; }
.entete.regie .deco { width: 40px; height: 40px; }

/* Menu de navigation : curseur PMD */
.nav { display: flex; justify-content: space-around; padding: 0 2px 2px; font-size: 21px; }
.nav a { display: flex; align-items: center; gap: 4px; color: var(--gris); padding: 2px 0; }
.nav a.actif, .nav a:hover { color: var(--blanc); }
.nav a::before { content: ''; width: 22px; height: 22px; flex: none; }
.nav a.actif::before { background: url('/ui/curseur.png') center / 22px no-repeat; image-rendering: pixelated; }

/* Portrait PMD encadré */
.port { flex: none; width: 40px; height: 40px; box-sizing: content-box; display: inline-block; vertical-align: middle;
  border: 4px solid transparent; border-image: url('/ui/portrait-bleu.png') 4 / 4px / 0 stretch; image-rendering: pixelated; background: var(--case); }
.port img { width: 40px; height: 40px; display: block; }
.port.g { width: 80px; height: 80px; border-width: 8px; border-image-width: 8px; }
.port.g img { width: 80px; height: 80px; }
.port.or { border-image-source: url('/ui/portrait-vert.png'); }
.port.rose { border-image-source: url('/ui/portrait-rose.png'); }

/* Sprite PMD animé (repos, de face) */
.sprite {
  flex: none; display: inline-block; background-repeat: no-repeat; image-rendering: pixelated;
  width: calc(var(--l) * var(--z) * 1px); height: calc(var(--h) * var(--z) * 1px);
  background-size: calc(var(--l) * var(--n) * var(--z) * 1px) calc(var(--h) * var(--dirs) * var(--z) * 1px);
  animation: sprite-repos var(--t) steps(var(--n)) infinite;
}
@keyframes sprite-repos { to { background-position-x: calc(var(--l) * var(--n) * var(--z) * -1px); } }
@media (prefers-reduced-motion: reduce) { .sprite, .curs, .fleche { animation: none !important; } }
.case-sprite { display: grid; place-items: center; overflow: hidden; flex: none; }

/* Photo de profil (ou initiale) */
.photo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--or);
  background: var(--case); display: inline-grid; place-items: center; font-size: 16px; color: var(--or); vertical-align: middle; }
.photo.grande { width: 56px; height: 56px; border-width: 3px; font-size: 28px; }

/* Types */
.typ { width: 18px; height: 18px; vertical-align: -3px; }

/* Record */
.record { display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #1a1f3af2 45%, #1a1f3a88), url('/ui/arene.png') 50% 40% / 700px auto padding-box; }
.record > img { width: 48px; height: 48px; }
.record .valeur { font-size: 46px; color: var(--or); line-height: 1; white-space: nowrap; }

/* Lignes de classement */
.ligne { display: flex; align-items: center; gap: 10px; padding: 6px 0; min-width: 0; }
.ligne + .ligne { border-top: 2px solid var(--trait); }
.rang { width: 26px; text-align: center; font-size: 22px; flex: none; color: var(--gris); }
.rang-1 { color: #ffd84a; font-size: 24px; } .rang-2 { color: #d8e0f0; font-size: 24px; } .rang-3 { color: #e3a066; font-size: 24px; }
.ident { flex: 1; min-width: 0; }
.pseudo { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk { color: var(--cyan); font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.val { font-size: 24px; white-space: nowrap; color: var(--orange); text-align: right; }
.sous-val { font-size: 15px; color: var(--gris); text-align: right; white-space: nowrap; }

/* Podiums : onglets K.O. / Mission / Ratio */
.onglets { display: flex; gap: 4px; margin: -2px 0 6px; flex-wrap: wrap; }
.onglets button, .bouton {
  font: inherit; font-size: 19px; color: var(--gris); text-shadow: inherit; background: none; border: 0; padding: 2px 8px; cursor: pointer;
}
.onglets button.actif { color: var(--blanc); background: var(--trait); }
.onglets button:hover { color: var(--blanc); }
.podiums-grands { display: none; }

/* Champs, recherche, tri */
.champ, .outils input, .outils select {
  font: inherit; color: var(--blanc); text-shadow: none; background: #0a0c1c; border: 2px solid var(--bord); border-radius: 0;
  padding: 6px 8px; max-width: 100%; width: 100%;
}
.champ:focus, .outils input:focus, .outils select:focus { border-color: var(--or); outline: none; }
.champ::placeholder, .outils input::placeholder { color: var(--gris); }
select.champ, .outils select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background: #0a0c1c url('/ui/fleche-bas.png') right 8px center / 18px no-repeat; }
select option { background: var(--nuit); }
.outils { display: grid; gap: 6px; margin-bottom: 6px; }
.tri { color: var(--gris); font-size: 18px; display: flex; gap: 2px 4px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.tri button { font: inherit; font-size: 18px; color: var(--gris); text-shadow: inherit; background: none; border: 0; padding: 2px 4px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 2px; }
.tri button.actif { color: var(--blanc); }
.tri button.actif::before { content: ''; width: 16px; height: 16px; background: url('/ui/fleche-bas.png') center / 16px no-repeat; image-rendering: pixelated; }
.tri button.actif.monte::before { transform: rotate(180deg); }
.liste .chiffres { display: none; }
.plus { display: block; margin: 8px auto 0; }

/* Boutons PMD (curseur au survol) */
.bouton { display: inline-flex; align-items: center; gap: 4px; color: var(--blanc); font-size: 21px; padding: 4px 6px; }
.bouton::before { content: ''; width: 22px; height: 22px; flex: none; }
.bouton:hover::before, .bouton:focus-visible::before, .bouton.principal::before { background: url('/ui/curseur.png') center / 22px no-repeat; image-rendering: pixelated; }
.bouton:hover { color: var(--or); }
.bouton.danger { color: var(--rouge); }
.bouton.petit { font-size: 18px; padding: 2px 4px; }
.bouton.petit::before { width: 18px; height: 18px; background-size: 18px !important; }

/* Fiche joueur */
.dial { display: flex; gap: 12px; align-items: flex-start; }
.dial .txt { flex: 1; min-width: 0; }
.dial .nom { font-size: 24px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.dial .nom b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene {
  height: 190px; position: relative; overflow: hidden; display: grid; place-items: end center; padding-bottom: 6px;
  background: url('/ui/camp.png') -520px -310px / 1104px auto; image-rendering: pixelated;
  border: 3px solid var(--trait); margin: 8px 0;
}
.scene .ombre { position: absolute; bottom: 8px; left: 50%; width: 90px; margin-left: -45px; height: 18px; border-radius: 50%; background: #0006; }
.scene .sprite { position: relative; }
.scene .etiq { position: absolute; left: 8px; top: 6px; font-size: 19px; color: var(--or); }
.barre { display: grid; grid-template-columns: 82px 1fr 52px; gap: 8px; align-items: center; margin: 4px 0; }
.barre .j { height: 12px; background: #0a0c1c; border: 2px solid var(--bord); position: relative; }
.barre .j i { position: absolute; inset: 0 auto 0 0; background: var(--vert); box-shadow: inset 0 -3px #2aa147, inset 0 3px #93f5a7; }
.barre .j i.o { background: var(--orange); box-shadow: inset 0 -3px #c8641e, inset 0 3px #ffc58a; }
.barre .j i.b { background: var(--bleu); box-shadow: inset 0 -3px #2b8fc4, inset 0 3px #b8e9ff; }
.barre .n { text-align: right; }
.transfo { display: flex; align-items: center; gap: 10px; }
.transfo img { width: 44px; height: 44px; }
.totaux { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 8px 4px; }
.totaux b { display: block; font-size: 32px; line-height: 1.1; }
.totaux span { font-size: 17px; color: var(--gris); }
.graphe { display: flex; align-items: flex-end; gap: 6px; height: 120px; overflow-x: auto; }
.graphe div { flex: 0 1 56px; min-width: 28px; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; font-size: 15px; color: var(--gris); }
.graphe div span:first-child { color: var(--blanc); }
.graphe i { width: 100%; min-height: 3px; background: var(--bleu); box-shadow: inset 0 3px #b8e9ff, inset 0 -3px #2b8fc4; border: 2px solid var(--contour); }
.passes { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.passes > div { text-align: center; background: var(--case); border: 2px solid var(--bord); padding: 6px 2px; font-size: 16px; min-width: 0; }
.passes .case-sprite { margin: 0 auto 2px; width: 90px; height: 72px; }
.passes .doux { font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 4px; border-top: 2px solid var(--trait); text-align: left; font-size: 18px; vertical-align: middle; }
th { color: var(--gris); font-weight: normal; font-size: 16px; border-top: 0; }
td.n, th.n { text-align: right; }
.defile-x { overflow-x: auto; }

/* Lives */
.live .haut { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.live .infos { display: flex; gap: 4px 14px; color: var(--gris); font-size: 18px; margin: 4px 0 6px; align-items: center; flex-wrap: wrap; }
.live .infos img { width: 24px; height: 24px; vertical-align: -5px; }
.mvp { display: flex; align-items: center; gap: 8px; background: var(--case); padding: 5px 8px; border: 2px solid var(--bord); min-width: 0; }
.mvp:hover { border-color: var(--or); }
.compteur { display: flex; align-items: center; gap: 10px; }
.compteur img { width: 40px; height: 40px; }

/* Régie */
.menu-regie { display: flex; flex-wrap: wrap; gap: 0 6px; }
.menu-regie .bouton { color: var(--gris); }
.menu-regie .bouton.actif { color: var(--blanc); }
.menu-regie .bouton.actif::before { background: url('/ui/curseur.png') center / 22px no-repeat; image-rendering: pixelated; }
.ligne-regie { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-top: 2px solid var(--trait); }
.ligne-regie:first-child { border-top: 0; }
.ligne-regie .grow { flex: 1 1 200px; min-width: 0; }
.ligne-regie .actions { display: flex; flex-wrap: wrap; gap: 0 4px; }
.detail { flex-basis: 100%; background: #141833; border: 2px solid var(--bord); padding: 8px; }
.detail .champ { width: auto; }
.detail td .champ { width: 4.6em; padding: 4px; font-size: 17px; }
.case-a-cocher { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; }
.case-a-cocher input { width: 18px; height: 18px; accent-color: var(--or); }
.formulaire { display: grid; gap: 8px; }
.formulaire label { display: grid; gap: 4px; color: var(--cyan); }
.masque { opacity: 0.5; }
.message { margin: 0 10px 10px; padding: 8px 12px; background: var(--case); border: 2px solid var(--vert); color: var(--vert); }
.message.erreur { border-color: var(--rouge); color: var(--rouge); }
.vide { padding: 20px; text-align: center; color: var(--gris); }

/* Boîte de dialogue PMD (confirmation) */
.voile { position: fixed; inset: 0; background: #050614b3; z-index: 10; display: flex; align-items: flex-end; justify-content: center; padding: 0 0 24px; }
.voile .fen { width: min(560px, calc(100% - 4px)); margin: 0 2px; }
.voile .choix { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.fleche { width: 22px; height: 22px; display: block; margin: 0 auto -6px; animation: rebond 0.8s steps(2) infinite; }
@keyframes rebond { 50% { transform: translateY(4px); } }
.curs { display: inline-block; width: 3px; height: 22px; background: var(--blanc); animation: clign 1s steps(1) infinite; vertical-align: middle; }
@keyframes clign { 50% { opacity: 0; } }

/* Ordinateur : plus de place */
@media (min-width: 760px) {
  .entete { height: 190px; background-size: 1380px auto; background-position: center -380px; padding: 0 28px 16px; }
  .entete h1 { font-size: 44px; }
  .entete .deco { right: 40px; top: 70px; }
  .colonnes { display: grid; grid-template-columns: 1fr 1fr; align-items: start; padding: 0 5px; }
  .colonnes .fen { margin: 0 5px 10px; }
  .podium-mobile { display: none; }
  .podiums-grands { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 5px; }
  .podiums-grands .fen { margin: 0 5px 10px; }
  .liste .ligne .chiffres { display: flex; gap: 0; }
  .liste .chiffres span { width: 76px; text-align: right; font-size: 20px; color: var(--blanc); }
  .liste .chiffres span.orange { color: var(--orange); }
  .liste .resume { display: none; }
  .tri { justify-content: flex-end; gap: 0; }
  .tri .etiq-tri { order: -2; }
  .tri button[data-col="pseudo"] { order: -1; margin-right: auto; padding-left: 92px; }
  .tri button:not([data-col="pseudo"]) { width: 76px; justify-content: flex-end; padding: 2px 0; }
  .lives-grille { display: grid; grid-template-columns: 1fr 1fr; padding: 0 5px; }
  .lives-grille .fen { margin: 0 5px 10px; }
}
