:root { --fond: rgba(10, 16, 26, .82); --bord: rgba(140, 190, 255, .28); --txt: #e8eef6; --acc: #ffb040; --bleu: #5ab0ff; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05070c; color: var(--txt); font: 15px/1.35 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }

#titre { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 30% 20%, rgba(255,150,80,.18), transparent 60%), rgba(3,6,12,.55); z-index: 30; padding: 16px; }
.carte-titre { max-width: 520px; background: var(--fond); border: 1px solid var(--bord); border-radius: 16px; padding: 22px 22px 16px; backdrop-filter: blur(6px); }
.carte-titre h1 { margin: 0; font-size: 40px; letter-spacing: .14em; color: var(--acc); }
.carte-titre .sous { margin: 2px 0 12px; color: #9fb6cc; text-transform: uppercase; letter-spacing: .2em; font-size: 12px; }
.boutons { display: flex; gap: 10px; margin: 16px 0 8px; flex-wrap: wrap; }
.boutons button { flex: 1; min-width: 150px; padding: 13px; border-radius: 10px; border: 0; background: var(--acc); color: #1a1206; font-weight: 700; font-size: 16px; }
#b-nouveau { background: #2b3a50; color: var(--txt); }
.petit { font-size: 12.5px; color: #9fb0c3; }

.puce { background: var(--fond); border: 1px solid var(--bord); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; white-space: nowrap; }
#haut { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; z-index: 10; flex-wrap: wrap; pointer-events: none; }
#haut > * { pointer-events: auto; }
#menu-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--fond); border: 1px solid var(--bord); font-size: 20px; }
#credits { color: var(--acc); font-weight: 700; }
#objectif { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 48px); left: 10px; max-width: min(440px, calc(100vw - 20px)); white-space: normal; border-radius: 12px; border-color: rgba(255,176,64,.5); z-index: 9; font-size: 13px; }
#objectif:empty { display: none; }
#objectif b { color: var(--acc); }

#vol { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; display: flex; gap: 6px; z-index: 9; }
#vol > div { background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; padding: 4px 9px; text-align: center; min-width: 62px; }
#vol b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
#vol small { font-size: 10px; color: #9fb0c3; text-transform: uppercase; letter-spacing: .05em; }
#vol .carbu { width: 74px; }
#vol .carbu i { display: block; height: 8px; margin: 6px 0 5px; border-radius: 4px; background: linear-gradient(90deg, var(--acc) var(--p, 100%), rgba(255,255,255,.1) var(--p, 100%)); }
body.apied #vol { display: none; }

#pilote { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: 10px; background: rgba(20,60,110,.85); border: 1px solid var(--bleu); border-radius: 10px; padding: 6px 10px; font-size: 13px; z-index: 9; max-width: 260px; }
#pilote button { margin-left: 8px; background: none; border: 1px solid #fff6; border-radius: 6px; padding: 1px 7px; }
#scanner { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 100px); right: 10px; background: var(--fond); border: 1px solid var(--bord); border-radius: 10px; padding: 5px 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; z-index: 9; }
#sc-fleche { display: inline-block; font-size: 20px; color: var(--acc); }
#sac { position: fixed; bottom: calc(150px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); }

#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lab { position: absolute; transform: translate(-50%, -100%); font-size: 12px; white-space: nowrap; background: rgba(8,12,20,.7); border: 1px solid var(--bord); border-radius: 6px; padding: 2px 6px; }
.lab.st { color: #9fd4ff; }
.lab.pl { color: #ffd59a; font-weight: 600; font-size: 13px; }
.lab.gis { color: #f0b0ff; }
.lab.moi { color: #a8ffb0; }
.lab.cible { border-color: var(--acc); color: var(--acc); }

#msg { position: fixed; left: 50%; top: 32%; transform: translateX(-50%); z-index: 12; pointer-events: none; text-align: center; max-width: min(560px, calc(100vw - 32px)); }
#msg div { background: rgba(10,16,26,.9); border: 1px solid var(--acc); border-radius: 10px; padding: 8px 14px; margin-bottom: 6px; animation: msg 4.5s forwards; }
@keyframes msg { 0% { opacity: 0; transform: translateY(8px); } 6% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; } }

#actions { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 11; align-items: center; width: min(330px, calc(100vw - 260px)); min-width: 190px; }
#actions button { width: 100%; padding: 12px 10px; border-radius: 12px; border: 1px solid rgba(255,176,64,.6); background: rgba(40,28,10,.88); font-weight: 650; font-size: 14.5px; }
#actions button.prim { background: var(--acc); color: #1a1206; border-color: var(--acc); }

#joy { position: fixed; left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.22); z-index: 11; touch-action: none; }
#joy-k { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: rgba(255,255,255,.3); border: 2px solid rgba(255,255,255,.5); }
#lev { position: fixed; right: calc(18px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 62px; height: 190px; border-radius: 14px; background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.22); z-index: 11; overflow: hidden; touch-action: none; }
#lev-fill { position: absolute; left: 0; right: 0; background: rgba(255,176,64,.55); }
#lev-fill.desc { background: rgba(90,176,255,.6); }
#lev .mi { position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: #fff9; }
#lev b { position: absolute; left: 0; right: 0; text-align: center; font-size: 9.5px; letter-spacing: -.02em; color: #fffc; font-weight: 600; line-height: 1.15; pointer-events: none; }
#lev-h { top: 6px; } #lev-b { bottom: 6px; }
#lev.poussee .mi { display: none; }
#boutons-vol { position: fixed; right: calc(92px + env(safe-area-inset-right)); bottom: calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; z-index: 11; }
#boutons-vol button { width: 60px; height: 56px; border-radius: 12px; background: var(--fond); border: 1px solid var(--bord); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#boutons-vol small { font-size: 9.5px; }
#b-croisiere.on { background: var(--acc); color: #1a1206; }
body.apied #lev, body.apied #b-croisiere { display: none !important; }

#panneau, #menu { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.45); padding: 12px; }
.pan { width: min(640px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: auto; background: #0d1520f2; border: 1px solid var(--bord); border-radius: 14px; padding: 0 14px 14px; touch-action: pan-y; user-select: text; }
.pan header { position: sticky; top: 0; background: #0d1520; display: flex; justify-content: space-between; align-items: center; padding: 12px 0 8px; border-bottom: 1px solid var(--bord); margin-bottom: 10px; z-index: 1; }
.pan h2 { margin: 0; font-size: 18px; color: var(--acc); }
.pan header button { width: 36px; height: 36px; border-radius: 8px; background: #22303f; border: 0; font-size: 16px; }
.petit-pan { width: min(420px, 100%); }
.petit-pan > button { display: block; width: 100%; text-align: left; padding: 12px; margin-bottom: 8px; border-radius: 10px; background: #1a2635; border: 1px solid var(--bord); }
.petit-pan > button.danger { color: #ff9d8a; }
.pan h3 { font-size: 14px; margin: 14px 0 6px; color: #9fd4ff; text-transform: uppercase; letter-spacing: .06em; }
.pan table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pan td, .pan th { padding: 6px 4px; border-bottom: 1px solid #ffffff12; text-align: left; vertical-align: middle; }
.pan th { font-size: 11px; color: #9fb0c3; font-weight: 500; text-transform: uppercase; }
.pan td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pan .bt { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--bord); background: #1f3045; margin: 2px; font-size: 13px; white-space: nowrap; }
.pan .bt.or { background: var(--acc); color: #1a1206; border-color: var(--acc); font-weight: 650; }
.pan .bt:disabled { opacity: .35; cursor: default; }
.pan .info { background: #16222f; border-radius: 10px; padding: 8px 10px; font-size: 13.5px; color: #c9d6e3; margin: 6px 0; }
.pan .ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #ffffff12; }
.pan .ligne > div { flex: 1; } .pan .ligne small { color: #9fb0c3; display: block; }
.barre { height: 8px; background: #ffffff18; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.barre i { display: block; height: 100%; background: var(--acc); }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.onglets button { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--bord); background: #16222f; font-size: 13px; }
.onglets button.on { background: var(--bleu); color: #04121f; border-color: var(--bleu); font-weight: 650; }

@media (max-width: 700px) {
  #vol > div { min-width: 52px; padding: 3px 6px; }
  #vol b { font-size: 13px; }
  #vol { top: calc(max(10px, env(safe-area-inset-top)) + 46px); }
  #objectif { top: calc(max(10px, env(safe-area-inset-top)) + 96px); }
  body.apied #objectif { top: calc(max(10px, env(safe-area-inset-top)) + 48px); }
  #pilote { top: calc(max(10px, env(safe-area-inset-top)) + 150px); }
  #scanner { top: calc(max(10px, env(safe-area-inset-top)) + 150px); }
  #pilote:not([hidden]) ~ #scanner { top: calc(max(10px, env(safe-area-inset-top)) + 190px); }
  #actions { width: calc(100vw - 300px); min-width: 150px; }
  #actions button { font-size: 13px; padding: 10px 6px; }
  #joy { width: 112px; height: 112px; }
}
@media (max-width: 700px) and (orientation: portrait) {
  #actions { bottom: calc(225px + env(safe-area-inset-bottom)); width: calc(100vw - 32px); }
  body.apied #actions { bottom: calc(150px + env(safe-area-inset-bottom)); }
  #sac { bottom: calc(360px + env(safe-area-inset-bottom)); }
}

#nouveau-form label { display: block; font-size: 13px; color: #9fb6cc; margin: 10px 0 6px; }
#nouveau-form input { display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 8px; border: 1px solid var(--bord); background: #0b121c; color: var(--txt); font: inherit; font-size: 16px; user-select: text; }
.persos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.persos button { flex: 1; min-width: 88px; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--bord); background: #16222f; font-size: 12.5px; }
.persos button.on { border-color: var(--acc); background: #3a2a10; color: var(--acc); font-weight: 650; }
.boutons button:disabled { opacity: .45; }
#etoiles { position: fixed; inset: 0; z-index: 25; background: #04060c; display: flex; flex-direction: column; }
#etoiles header { display: flex; justify-content: space-between; align-items: center; padding: max(10px, env(safe-area-inset-top)) 12px 8px; gap: 8px; }
#etoiles h2 { margin: 0; font-size: 17px; color: var(--acc); }
#etoiles header button { margin-left: 6px; padding: 7px 10px; border-radius: 8px; background: #1a2635; border: 1px solid var(--bord); font-size: 13px; }
#et-canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; }
#et-info { width: 100%; max-height: 42vh; border-radius: 14px 14px 0 0; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); font-size: 14px; }
#et-info .ligne small { display: block; }
#maj { position: fixed; top: 40%; left: 50%; transform: translateX(-50%); z-index: 40; background: var(--acc); color: #1a1206; padding: 10px 16px; border-radius: 10px; font-weight: 700; }
@media (orientation: landscape) and (max-height: 520px) {
  #etoiles { flex-direction: row; flex-wrap: wrap; }
  #etoiles header { width: 100%; }
  #et-canvas { width: 60%; height: calc(100% - 56px); flex: none; }
  #et-info { width: 40%; max-height: calc(100% - 56px); height: calc(100% - 56px); border-radius: 14px 0 0 0; }
}
#titre { overflow-y: auto; place-items: start center; touch-action: pan-y; }
.carte-titre { margin: auto 0; }
#titre::before { content: ''; } 
@media (max-height: 520px) {
  .carte-titre { padding: 12px 16px 10px; }
  .carte-titre h1 { font-size: 26px; }
  .carte-titre > p:not(.sous):not(.petit):not(#chargement) { display: none; }
  .boutons { margin: 8px 0 4px; }
  .boutons button { padding: 10px; }
  .persos button { padding: 6px 4px; min-width: 70px; }
}

#b-booster { display: none !important; }
body.apied #b-booster { display: flex !important; width: 76px !important; height: 76px !important; font-size: 26px !important; background: linear-gradient(0deg, rgba(255,140,40,.55) var(--p, 100%), rgba(10,16,26,.82) var(--p, 100%)) !important; border-color: rgba(255,160,64,.7) !important; touch-action: none; }
body.apied #b-booster.on { border-color: #fff !important; }
body.apied #boutons-vol { right: calc(18px + env(safe-area-inset-right)); align-items: flex-end; }

/* à pied : actions en icônes, en haut à droite */
body.apied #actions.compact, #actions.compact { left: auto; right: calc(10px + env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); bottom: auto; transform: none; width: auto; min-width: 0; flex-direction: row-reverse; gap: 8px; }
#actions.compact button { position: relative; width: 54px; height: 54px; padding: 0; border-radius: 14px; display: grid; place-items: center; }
#actions.compact .ic { font-size: 26px; line-height: 1; }
#actions.compact .q { position: absolute; right: 3px; bottom: 2px; font-size: 12px; font-weight: 800; background: rgba(0,0,0,.55); color: #fff; border-radius: 6px; padding: 0 4px; }
#actions.compact .k { position: absolute; left: 4px; top: 2px; font-size: 10px; opacity: .7; }
body.apied #scanner { top: calc(max(10px, env(safe-area-inset-top)) + 64px); }
@media (max-width: 700px) and (orientation: portrait) {
  body.apied #actions.compact { top: 42%; flex-direction: column; }
}
/* boussole du gisement : en bas à gauche, au-dessus du joystick (ne chevauche plus l'objectif) */
#scanner, body.apied #scanner, #pilote:not([hidden]) ~ #scanner { top: auto !important; right: auto; left: calc(10px + env(safe-area-inset-left)); bottom: calc(165px + env(safe-area-inset-bottom)); }
@media (max-width: 700px) { #scanner, body.apied #scanner { bottom: calc(148px + env(safe-area-inset-bottom)); } }

#b-msg { width: 40px; height: 40px; border-radius: 10px; background: var(--fond); border: 1px solid var(--bord); font-size: 18px; position: relative; }
#b-msg.nouveau::after { content: ''; position: absolute; top: 4px; right: 4px; width: 9px; height: 9px; border-radius: 50%; background: #ff5050; }
#lieu.horsligne::after { content: ' · hors ligne'; color: #ff9d8a; }
.msgs { max-height: 38vh; overflow: auto; background: #0a111a; border-radius: 10px; padding: 8px; margin: 8px 0; }
.msg { padding: 3px 0; font-size: 14px; } .msg b { color: #9fd4ff; } .msg.moi b { color: var(--acc); }
.phrases { display: flex; flex-wrap: wrap; gap: 4px; }
.ligne-msg { display: flex; gap: 6px; margin-top: 8px; }
.ligne-msg input { flex: 1; min-width: 0; padding: 9px; border-radius: 8px; border: 1px solid var(--bord); background: #0b121c; color: var(--txt); font: inherit; font-size: 16px; }
.lien { background: none; border: 0; color: #9fd4ff; text-decoration: underline; padding: 6px 0; font-size: 13px; }
#auth form label { display: block; font-size: 13px; color: #9fb6cc; margin: 8px 0 4px; }
#auth input { display: block; width: 100%; margin-top: 4px; padding: 10px; border-radius: 8px; border: 1px solid var(--bord); background: #0b121c; color: var(--txt); font: inherit; font-size: 16px; user-select: text; }
#auth-msg.ok { color: #a8ffb0; } #auth-msg.err { color: #ff9d8a; }
#auth .onglets { margin: 10px 0 4px; }
.carte-titre a { color: #9fd4ff; }
.petit-pan > a.bouton-menu { display: block; padding: 12px; margin-bottom: 8px; border-radius: 10px; background: #1a2635; border: 1px solid var(--bord); color: var(--txt); text-decoration: none; }
.carte-titre { width: 100%; min-width: 0; }
.carte-titre h1 { font-size: clamp(26px, 9vw, 40px); }
.carte-titre .intro { font-size: 14px; }
@media (max-width: 520px) { .carte-titre .intro { display: none; } }

.form-ligne { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.form-ligne select, .form-ligne input { flex: 1; min-width: 80px; padding: 8px; border-radius: 8px; border: 1px solid var(--bord); background: #0b121c; color: var(--txt); font: inherit; font-size: 15px; }
.form-ligne select { flex: 2; min-width: 140px; }
.form-ligne label.mini { flex: 1; min-width: 90px; font-size: 11px; color: #9fb0c3; display: flex; flex-direction: column; gap: 2px; }
.form-ligne label.mini input { min-width: 0; width: 100%; }
.form-ligne > .bt { align-self: flex-end; }
#vol .carbu i.coque { background: linear-gradient(90deg, #7fd8a0 var(--p, 100%), rgba(255,255,255,.1) var(--p, 100%)); margin-top: 3px; }
#vol .carbu.alerte i.coque { background: linear-gradient(90deg, #ff6050 var(--p, 100%), rgba(255,255,255,.1) var(--p, 100%)); }
#vol .carbu { line-height: 1; }
