/* Furia Quest — habillage. Nuit prune, néon rose, or de parchemin, bords en pixels. */
@font-face { font-family: 'Press Start 2P'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../polices/press-start-2p-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'Press Start 2P'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../polices/press-start-2p-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../polices/vt323-latin-ext-400-normal.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2113; }
@font-face { font-family: 'VT323'; font-style: normal; font-weight: 400; font-display: swap;
  src: url(../polices/vt323-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215; }

:root {
  --nuit: #140a1f; --prune: #2a1440; --prune2: #3d1f5c; --bord: #6b3fa0;
  --rose: #ff3d9a; --rose-sombre: #a8145c; --or: #f2c14e; --lait: #f4e9ff; --doux: #c3add9;
  --vert: #5ee6a8; --rouge: #ff5a5f; --bleu: #6fb7ff;
  --titre: 'Press Start 2P', 'Courier New', monospace;
  --texte: 'VT323', 'Courier New', monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--nuit); color: var(--lait); overflow: hidden;
  font-family: var(--texte); font-size: 22px; line-height: 1.15; -webkit-tap-highlight-color: transparent; }
body { touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
p { margin: 0 0 .55em; }

#jeu { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; }

/* ---------- Bords en pixels ---------- */
.px { position: relative; background: var(--prune); margin: 4px;
  box-shadow: 0 -4px 0 0 var(--bord), 0 4px 0 0 var(--bord), -4px 0 0 0 var(--bord), 4px 0 0 0 var(--bord), 0 10px 0 0 rgba(0, 0, 0, .35); }

.btn { font-family: var(--titre); font-size: 11px; line-height: 1.5; padding: 13px 14px; min-height: 46px; border: 0; cursor: pointer;
  background: var(--rose); color: #24051a; margin: 4px; text-align: center;
  box-shadow: 0 -4px 0 0 var(--rose-sombre), 0 4px 0 0 var(--rose-sombre), -4px 0 0 0 var(--rose-sombre), 4px 0 0 0 var(--rose-sombre), 0 8px 0 0 rgba(0, 0, 0, .4); }
.btn:active:not(:disabled) { transform: translateY(3px); }
.btn.sec { background: var(--prune2); color: var(--lait);
  box-shadow: 0 -4px 0 0 var(--bord), 0 4px 0 0 var(--bord), -4px 0 0 0 var(--bord), 4px 0 0 0 var(--bord), 0 8px 0 0 rgba(0, 0, 0, .4); }
.btn:disabled { opacity: .42; cursor: default; }
.btn small { display: block; font-family: var(--texte); font-size: 17px; line-height: 1; margin-top: 3px; opacity: .85; }
:focus-visible { outline: 3px solid var(--or); outline-offset: 3px; }

.barre { height: 12px; background: #0c0612; box-shadow: 0 0 0 2px #000; position: relative; overflow: hidden; }
.barre i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--vert); transition: width .28s steps(8); }
.barre.end i { background: var(--bleu); }
.barre.bas i { background: var(--rouge); }

/* ---------- Affichage en jeu ---------- */
#hud { position: fixed; left: 0; right: 0; top: 0; padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.hud-etat { padding: 8px 10px; min-width: 176px; background: rgba(42, 20, 64, .92); }
.hud-ligne { display: flex; justify-content: space-between; gap: 10px; font-family: var(--titre); font-size: 9px; margin-bottom: 6px; }
.hud-ligne b { color: var(--or); font-weight: 400; }
.hud-jauge { display: grid; grid-template-columns: 34px 1fr 62px; align-items: center; gap: 6px; font-size: 18px; line-height: 1; margin-top: 4px; }
.hud-jauge span:last-child { text-align: right; }
.hud-boutons { display: flex; gap: 2px; }
.hud-boutons .btn { padding: 10px 10px; min-height: 40px; font-size: 9px; }
#suivi { position: fixed; left: calc(12px + env(safe-area-inset-left)); top: calc(100px + env(safe-area-inset-top)); max-width: min(74vw, 420px); z-index: 4;
  background: rgba(20, 10, 31, .82); padding: 5px 9px; font-size: 19px; line-height: 1.05; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.fleche { width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 13px solid var(--or); flex: none; }
#terrain { position: fixed; right: calc(12px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 4;
  background: rgba(20, 10, 31, .82); padding: 5px 9px; font-size: 19px; line-height: 1.05; text-align: right; pointer-events: none; max-width: 48vw; }
#terrain b { font-family: var(--titre); font-size: 9px; font-weight: 400; color: var(--or); display: block; margin-bottom: 3px; }

#croix { position: fixed; left: calc(14px + env(safe-area-inset-left)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6;
  display: none; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 2px; }
#croix button { border: 0; background: rgba(42, 20, 64, .78); box-shadow: inset 0 0 0 3px rgba(255, 61, 154, .75); cursor: pointer; position: relative; }
#croix button:active, #croix button.actif { background: rgba(255, 61, 154, .6); }
#croix button::after { content: ''; position: absolute; left: 50%; top: 50%; border: 9px solid transparent; }
#croix .haut { grid-area: 1 / 2; } #croix .haut::after { border-bottom-color: var(--lait); transform: translate(-50%, -75%); }
#croix .bas { grid-area: 3 / 2; } #croix .bas::after { border-top-color: var(--lait); transform: translate(-50%, -25%); }
#croix .gauche { grid-area: 2 / 1; } #croix .gauche::after { border-right-color: var(--lait); transform: translate(-75%, -50%); }
#croix .droite { grid-area: 2 / 3; } #croix .droite::after { border-left-color: var(--lait); transform: translate(-25%, -50%); }
@media (pointer: coarse) { #croix:not([hidden]) { display: grid; } }
body.tactile #croix:not([hidden]) { display: grid; }

#eclair { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 20; }
#eclair.actif { animation: eclair .55s steps(2) 1; }
@keyframes eclair { 0%, 40%, 80% { opacity: .9; } 20%, 60%, 100% { opacity: 0; } }

/* ---------- Écrans ---------- */
#ecran { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; overflow: auto;
  padding: calc(10px + env(safe-area-inset-top)) 10px calc(14px + env(safe-area-inset-bottom)); background: rgba(12, 6, 18, .62); }
#ecran.titre { background: linear-gradient(180deg, rgba(20, 10, 31, .25), rgba(20, 10, 31, .88) 62%); }
.fenetre { width: min(100%, 560px); max-height: 100%; display: flex; flex-direction: column; padding: 14px; }
.fenetre h2 { font-family: var(--titre); font-size: 14px; line-height: 1.5; font-weight: 400; color: var(--or); margin: 0 0 8px; }
.fenetre .corps { overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; padding: 2px 4px 8px; touch-action: pan-y; }
.pile { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.rang { display: flex; gap: 4px; flex-wrap: wrap; }
.rang .btn { flex: 1 1 0; }
.doux { color: var(--doux); }
.or { color: var(--or); }

#dialogue { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center;
  padding: 10px 10px calc(22px + env(safe-area-inset-bottom)); background: rgba(12, 6, 18, .45); }
.bulle { width: min(100%, 620px); padding: 14px 14px 10px; }
.bulle .corps { max-height: 46vh; overflow: auto; touch-action: pan-y; }
.bulle h3 { font-family: var(--titre); font-size: 12px; line-height: 1.5; font-weight: 400; color: var(--or); margin: 0 0 8px; }

/* Titre */
.titre-bloc { text-align: center; width: min(100%, 460px); margin-top: 6vh; }
.logo { font-family: var(--titre); font-weight: 400; font-size: clamp(30px, 10.5vw, 60px); line-height: 1.12; margin: 0 0 14px; color: var(--or);
  text-shadow: 4px 4px 0 var(--rose-sombre), 8px 8px 0 #2a1440; letter-spacing: -1px; }
.sous { font-size: 24px; margin-bottom: 18px; text-shadow: 2px 2px 0 #000; }
.pied { margin-top: 16px; font-size: 19px; color: var(--doux); text-shadow: 2px 2px 0 #000; }

/* Menu */
.onglets { display: flex; gap: 2px; margin-bottom: 8px; }
.onglets .btn { flex: 1 1 0; padding: 10px 2px; font-size: 8px; min-height: 40px; }
.onglets .btn[aria-selected="true"] { background: var(--or); color: #24051a; }
.grille-stats { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; }
.grille-stats span:nth-child(even) { color: var(--or); text-align: right; }
.ligne { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 2px dotted rgba(195, 173, 217, .28); }
.ligne:last-child { border-bottom: 0; }
.ligne .btn { flex: none; padding: 9px 10px; min-height: 38px; font-size: 9px; }
.ligne div { min-width: 0; }
.ligne small { display: block; color: var(--doux); font-size: 18px; }
.quete { padding: 8px 0; border-bottom: 2px dotted rgba(195, 173, 217, .28); }
.quete:last-child { border-bottom: 0; }
.quete h4 { font-family: var(--titre); font-size: 10px; line-height: 1.5; font-weight: 400; margin: 0 0 4px; color: var(--lait); }
.quete .btn { margin-top: 8px; }
.etiquette { font-family: var(--titre); font-size: 8px; padding: 4px 6px; background: var(--prune2); color: var(--or); white-space: nowrap; }
#carte-monde { width: 100%; image-rendering: pixelated; display: block; background: #2c69c9; box-shadow: 0 0 0 3px #000; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 19px; }
.legende i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 2px #000; }

/* Village : portrait du personnage */
.portrait { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 6px; }
.portrait img { width: 92px; height: 116px; object-fit: cover; object-position: 50% 12%; flex: none; box-shadow: 0 0 0 3px var(--bord); background: #0c0612; }
.portrait b { font-family: var(--titre); font-size: 11px; font-weight: 400; color: var(--or); display: block; margin-bottom: 4px; line-height: 1.5; }

/* ---------- Combat ---------- */
#ecran.combat { background: radial-gradient(120% 90% at 50% 0%, #3a1a55 0%, #140a1f 62%); align-items: stretch; padding-top: calc(8px + env(safe-area-inset-top)); overflow: hidden; }
.combat-grille { display: flex; flex-direction: column; gap: 8px; max-width: 520px; margin: 0 auto; min-height: 0; flex: 1 1 auto; }
.zone-carte { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; perspective: 900px; padding: 6px 0 12px; }
.bas-combat { flex: none; display: flex; flex-direction: column; gap: 6px; }

.carte { --teinte: #ff3d9a; position: relative; height: 100%; max-height: 640px; aspect-ratio: 5 / 8; max-width: calc(100vw - 28px);
  display: flex; flex-direction: column; gap: 6px; padding: 10px; margin: 4px;
  background: #24113a; background: linear-gradient(180deg, color-mix(in srgb, var(--teinte) 34%, #1a0d29) 0%, #1a0d29 58%);
  box-shadow: 0 -4px 0 0 var(--teinte), 0 4px 0 0 var(--teinte), -4px 0 0 0 var(--teinte), 4px 0 0 0 var(--teinte), 0 12px 0 0 rgba(0, 0, 0, .45); }
.carte-tete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--titre); font-size: 13px; line-height: 1.4; }
.carte-tete span:last-child { color: var(--or); font-size: 9px; white-space: nowrap; }
.carte-image { position: relative; flex: 1 1 auto; min-height: 60px; background: #0c0612; box-shadow: 0 0 0 3px rgba(0, 0, 0, .6); overflow: hidden; }
.carte-image img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block; }
.carte-image img.centre { object-position: 50% 50%; } .carte-image img.bas { object-position: 50% 88%; }
.carte-type { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 21px; line-height: 1; }
.carte-pv { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; font-size: 19px; line-height: 1; }
.carte-attaques { background: rgba(0, 0, 0, .34); padding: 5px 8px; font-size: 19px; line-height: 1.12; }
.carte-attaques div { display: flex; justify-content: space-between; gap: 8px; }
.carte-attaques span { color: var(--doux); text-align: right; }
.carte-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; text-align: center; font-family: var(--titre); font-size: 8px; line-height: 1.5; }
.carte-stats b { display: block; font-size: 12px; font-weight: 400; color: var(--or); }
.carte-desc { font-size: 18px; line-height: 1.05; color: var(--doux); font-style: italic; }
.carte-etats { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.carte.boss { box-shadow: 0 -4px 0 0 var(--or), 0 4px 0 0 var(--or), -4px 0 0 0 var(--or), 4px 0 0 0 var(--or), 0 -8px 0 0 var(--teinte), 0 8px 0 0 var(--teinte), -8px 0 0 0 var(--teinte), 8px 0 0 0 var(--teinte), 0 16px 0 0 rgba(0, 0, 0, .45); }
.carte.boss .carte-image::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .28) 50%, transparent 60%); background-size: 260% 100%; animation: reflet 4.5s linear infinite; }
@keyframes reflet { 0% { background-position: 130% 0; } 55%, 100% { background-position: -130% 0; } }
.carte.entre { animation: entree .5s cubic-bezier(.2, .9, .3, 1.2) 1; }
@keyframes entree { 0% { transform: rotateY(88deg) scale(.86); opacity: 0; } 100% { transform: none; opacity: 1; } }
.carte.touche { animation: touche .32s steps(4) 1; }
@keyframes touche { 0%, 100% { transform: none; filter: none; } 25% { transform: translate(-7px, 2px); filter: brightness(2.2); } 50% { transform: translate(6px, -2px); } 75% { transform: translate(-3px, 1px); filter: brightness(1.5); } }
.carte.vaincue { animation: chute .7s ease-in 1 forwards; }
@keyframes chute { 0% { transform: none; filter: none; opacity: 1; } 100% { transform: translateY(40px) rotate(5deg); filter: grayscale(1) brightness(.5); opacity: .25; } }
.flot { position: absolute; left: 50%; top: 42%; transform: translateX(-50%); font-family: var(--titre); font-size: 22px; color: #fff; text-shadow: 3px 3px 0 #000; pointer-events: none; animation: flot .8s ease-out 1 forwards; white-space: nowrap; z-index: 3; }
.flot.crit { color: var(--or); font-size: 28px; } .flot.soin { color: var(--vert); } .flot.rate { color: var(--doux); font-size: 14px; }
@keyframes flot { 0% { transform: translate(-50%, 0); opacity: 1; } 100% { transform: translate(-50%, -54px); opacity: 0; } }

.journal { min-height: 3.5em; padding: 7px 10px; font-size: 21px; line-height: 1.12; background: rgba(12, 6, 18, .8); }
.journal div { opacity: .55; } .journal div:last-child { opacity: 1; }
.joueur { display: flex; gap: 10px; align-items: center; padding: 8px 10px; position: relative; }
.joueur img { width: 52px; height: 52px; object-fit: cover; object-position: 50% 10%; flex: none; box-shadow: 0 0 0 3px var(--bord); background: #0c0612; }
.joueur .infos { flex: 1; min-width: 0; }
.joueur .nom { display: flex; justify-content: space-between; font-family: var(--titre); font-size: 9px; margin-bottom: 5px; }
.joueur .nom span:last-child { color: var(--or); }
.joueur.touche { animation: touche .32s steps(4) 1; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.actions .btn { padding: 10px 4px; font-size: 9px; min-height: 48px; }
.actions.liste { grid-template-columns: 1fr 1fr; }
.actions.liste .btn { text-align: left; padding-left: 10px; }

@media (min-width: 860px) and (min-aspect-ratio: 11/10) {
  .combat-grille { flex-direction: row; flex: 0 1 980px; max-width: 980px; align-items: center; gap: 28px; }
  .zone-carte { flex: 0 0 auto; height: min(92vh, 660px); }
  .bas-combat { flex: 1 1 0; min-width: 0; }
  .journal { min-height: 5.8em; }
}
@media (max-height: 620px) and (max-width: 859px) {
  .carte-desc, .carte-attaques { display: none; }
}
@media (max-width: 380px) {
  html, body { font-size: 20px; }
  .hud-etat { min-width: 156px; }
}
@media (prefers-reduced-motion: reduce) {
  .carte.entre, .carte.touche, .joueur.touche, .carte.boss .carte-image::after, #eclair.actif { animation: none; }
  .barre i { transition: none; }
}
