:root {
  --bg: #070b1f; --panel: rgba(12, 18, 44, 0.88); --line: rgba(120, 150, 255, 0.25);
  --text: #e8ecff; --dim: #8f9bc8; --acc: #4d8bff; --acc2: #ffd23d; --danger: #ff4a3a;
  --pix: 'Silkscreen', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif; overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
input, select { -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
#view { position: fixed; inset: 0; display: block; }

/* ---------- Écrans ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: radial-gradient(ellipse at center, rgba(7, 11, 31, 0.25), rgba(7, 11, 31, 0.85));
  overflow: auto; touch-action: pan-y;
}
.panel {
  width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 22px 22px 16px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.panel.small { width: min(380px, 100%); text-align: center; }
.logo {
  font-family: var(--pix); font-weight: 700; font-size: clamp(40px, 10vw, 66px); margin: 0; letter-spacing: 3px; text-align: center;
  background: linear-gradient(180deg, #b8d0ff, #4d8bff 55%, #7a4dff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 18px rgba(77, 139, 255, 0.45));
}
h2 { font-family: var(--pix); letter-spacing: 2px; margin: 4px 0 14px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); margin: 0 0 8px; }
.tag { text-align: center; color: var(--dim); margin: 4px 0 18px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--dim); margin-bottom: 6px; }
input, select, button { font: inherit; color: inherit; }
input#name, input#code, select {
  width: 100%; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--acc); }
select option { background: #10163a; }
input#code { font-family: var(--pix); letter-spacing: 6px; text-transform: uppercase; text-align: center; max-width: 140px; }
button {
  cursor: pointer; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.13); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button.big { width: 100%; background: linear-gradient(180deg, #5b97ff, #3a66e0); border-color: transparent; font-size: 17px; padding: 13px; font-weight: 800; }
button.big:hover:not(:disabled) { background: linear-gradient(180deg, #6ea4ff, #4672ec); }
.chassis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chassis button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; }
.chassis button small { font-weight: 400; color: var(--dim); font-size: 11px; }
.chassis button.on { border-color: var(--acc); background: rgba(77, 139, 255, 0.18); }
.sliders { margin-top: 10px; display: grid; gap: 4px; }
.sl { display: grid; grid-template-columns: 90px 1fr 28px; align-items: center; gap: 10px; font-size: 13px; }
.sl b { text-align: right; font-family: var(--pix); }
input[type=range] { width: 100%; accent-color: var(--acc); }
input[type=range]:disabled { opacity: 0.5; }
.hint { color: var(--dim); font-size: 12.5px; margin: 6px 0 0; min-height: 1em; }
.mp { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row > select { flex: 1; }
.row > button { white-space: nowrap; }
.col { display: grid; gap: 8px; }
.help { margin-top: 12px; font-size: 13px; color: var(--dim); }
.help summary { cursor: pointer; color: var(--text); }
.help p { margin: 8px 0; line-height: 1.45; }
#netMsg { color: var(--acc2); }
@media (max-width: 480px) { .chassis { grid-template-columns: repeat(2, 1fr); } .row { flex-wrap: wrap; } input#code { max-width: none; flex: 1; } }

/* ---------- Interface en jeu ---------- */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; font-family: var(--pix); color: #dfe6ff; text-shadow: 0 1px 0 #000; }
#hud button { pointer-events: auto; }
#cross { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); border: 2px solid rgba(160, 255, 200, 0.45); border-radius: 50%; }
#cross::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; background: rgba(160, 255, 200, 0.85); border-radius: 50%; }
#msg {
  position: absolute; left: 0; right: 0; top: 24%; text-align: center; padding: 0 16px; font-size: clamp(18px, 4vw, 34px); letter-spacing: 2px;
  opacity: 0; transition: opacity 0.3s; color: #fff; text-shadow: 0 0 14px rgba(77, 139, 255, 0.9), 0 2px 0 #000;
}
#msg.on { opacity: 1; }
#flash { position: absolute; inset: 0; opacity: 0; }
#flash.go { animation: fl 0.45s ease-out; }
@keyframes fl { from { opacity: 1; } to { opacity: 0; } }
#bPause { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); width: 42px; height: 42px; padding: 0; font-family: var(--pix); background: rgba(6, 10, 28, 0.5); }
#board { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(184px + env(safe-area-inset-top)); min-width: 190px; background: rgba(6, 10, 28, 0.6); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 12px; }
#board .bt { color: var(--dim); font-size: 10px; margin-bottom: 4px; }
#board .br { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; }
#board .br i { width: 10px; height: 10px; border-radius: 2px; }
#board .br.me span { color: #fff; text-decoration: underline; }
#console {
  position: absolute; left: calc(16px + env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; gap: 12px; align-items: flex-end; background: rgba(6, 10, 28, 0.55); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
}
#radarBox { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); padding: 5px; border-radius: 50%; background: rgba(6, 10, 28, 0.55); border: 1px solid var(--line); }
#radar { width: 150px; height: 150px; display: block; }
.gauges { display: flex; flex-direction: column; gap: 6px; min-width: 200px; font-size: 11px; }
.g label { display: block; color: var(--dim); font-size: 10px; margin-bottom: 2px; }
.bar { height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #3d7bff, #8ab8ff); transition: width 0.15s; }
#ammo { background: linear-gradient(90deg, #d0a020, #ffe04a); }
.bar i.low { background: var(--danger); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.stats.small { color: var(--dim); font-size: 10px; }

body.touch #console { top: calc(8px + env(safe-area-inset-top)); bottom: auto; left: calc(8px + env(safe-area-inset-left)); padding: 6px; gap: 8px; }
body.touch #radar { width: 100px; height: 100px; }
body.touch #radarBox { top: calc(6px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); padding: 3px; }
body.touch #bPause { left: calc(50% - 50px); top: calc(8px + env(safe-area-inset-top)); }
body.touch #board { left: calc(8px + env(safe-area-inset-left)); right: auto; top: calc(126px + env(safe-area-inset-top)); min-width: 160px; }
body.touch .gauges { min-width: 150px; font-size: 9px; gap: 4px; }
body.touch #msg { top: 30%; }

/* ---------- Commandes tactiles (invisibles / fondues) ---------- */
#touch { position: fixed; inset: 0; z-index: 3; touch-action: none; }
#joyBase {
  position: absolute; left: calc(110px + env(safe-area-inset-left)); top: 72%; width: 124px; height: 124px; margin: -62px 0 0 -62px;
  border: 2px solid rgba(255, 255, 255, 0.7); border-radius: 50%; background: rgba(255, 255, 255, 0.05);
  opacity: 0.1; transition: opacity 0.9s; pointer-events: none;
}
#joyBase.on { opacity: 0.5; transition: opacity 0.1s; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; transform: translate(-50%, -50%); border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
#fireHint {
  position: absolute; right: calc(60px + env(safe-area-inset-right)); bottom: calc(50px + env(safe-area-inset-bottom)); width: 110px; height: 110px;
  border-radius: 50%; border: 2px solid rgba(255, 120, 100, 0.8); display: flex; align-items: center; justify-content: center;
  font-family: var(--pix); font-size: 13px; color: #fff; opacity: 0.1; transition: opacity 0.6s; pointer-events: none;
}
#fireHint.on { opacity: 0.45; transition: opacity 0.05s; }
.tbtn {
  position: absolute; width: 62px; height: 62px; padding: 0; border-radius: 50%; font-family: var(--pix); font-size: 10px;
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid rgba(255, 255, 255, 0.5); opacity: 0.25; transition: opacity 0.5s;
}
.tbtn.on { opacity: 0.8; transition: opacity 0.05s; }
#tPulse { right: calc(190px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); }
#tJump { right: calc(30px + env(safe-area-inset-right)); bottom: calc(185px + env(safe-area-inset-bottom)); }
#tView { left: calc(50% + 8px); top: calc(8px + env(safe-area-inset-top)); width: 42px; height: 42px; font-size: 8px; }

/* ---------- Invitations, rendez-vous, résultats ---------- */
button.primary { background: linear-gradient(180deg, #5b97ff, #3a66e0); border-color: transparent; }
button.wide { width: 100%; }
.sub { color: var(--acc2); margin: -6px 0 12px; font-size: 14px; }
.field.left { text-align: left; }
input[type=datetime-local] { width: 100%; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color-scheme: dark; }
.rdv {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255, 210, 61, 0.45); background: rgba(255, 210, 61, 0.08); font-size: 14px;
}
.rdv .row { margin: 0; }
.bigcode { font-family: var(--pix); font-size: 54px; letter-spacing: 10px; color: var(--acc2); margin: 2px 0 10px; }
.res { display: grid; gap: 6px; margin-bottom: 12px; text-align: left; }
.res .br { display: grid; grid-template-columns: 22px 12px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); }
.res .br:first-child { background: rgba(255, 210, 61, 0.14); }
.res .br em { font-style: normal; font-family: var(--pix); color: var(--dim); }
.res .br i { width: 12px; height: 12px; border-radius: 3px; }
.res .br b { font-family: var(--pix); }
.res .br.me span { text-decoration: underline; }
#resImg { display: block; max-height: 260px; max-width: 100%; margin: 0 auto 12px; border-radius: 12px; border: 1px solid var(--line); }
#room { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 8px 14px; font-family: var(--pix); font-size: 12px; letter-spacing: 2px; color: var(--acc2); background: rgba(6, 10, 28, 0.55); border-radius: 999px; white-space: nowrap; }
body.touch #room { top: auto; bottom: calc(10px + env(safe-area-inset-bottom)); }

/* ---------- Direction des impacts ---------- */
.hit { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; animation: hitfade 1.2s ease-out forwards; }
.hit::before {
  content: ''; position: absolute; left: -95px; top: calc(-1 * min(36vh, 36vw)); width: 190px; height: 60px; border-radius: 50%;
  border-top: 8px solid rgba(255, 50, 40, 0.95); filter: drop-shadow(0 0 10px rgba(255, 40, 30, 0.9));
}
.hit::after {
  content: ''; position: absolute; left: -13px; top: calc(-1 * min(36vh, 36vw) - 24px);
  border-left: 13px solid transparent; border-right: 13px solid transparent; border-bottom: 18px solid rgba(255, 60, 40, 0.95);
}
@keyframes hitfade { 0% { opacity: 0; } 8% { opacity: 1; } 60% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Classements, touches, parties publiques, radar déplaçable ---------- */
.center { text-align: center; }
.top8 { margin-top: 8px; }
.grow { flex: 1; }
button.small { padding: 6px 10px; font-size: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--dim); margin: 2px 0 10px; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--acc); }
.pubhead { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.pubhead h3 { margin: 0; }
.pub { display: grid; gap: 6px; margin-top: 8px; }
.pub .g { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 13px; }
.pub .g small { color: var(--dim); display: block; }
.pub .empty { color: var(--dim); font-size: 12.5px; }
.tabs { display: flex; gap: 6px; margin: 0 0 12px; }
.tabs button { flex: 1; padding: 8px; }
.tabs button.on { border-color: var(--acc); background: rgba(77, 139, 255, 0.18); }
.sc { max-height: 46vh; overflow: auto; }
.claim { margin-bottom: 10px; }
.claim label { display: block; font-size: 12px; color: var(--dim); margin-bottom: 4px; }
.claim input { flex: 1; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.lb { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 9px; font-size: 13px; }
.lb:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.lb.me { outline: 1px solid var(--acc); background: rgba(77, 139, 255, 0.14); }
.lb em { font-style: normal; font-family: var(--pix); color: var(--dim); }
.lb.r1 em { color: #ffd23d; } .lb.r2 em { color: #dfe4ee; } .lb.r3 em, .lb.r10 em { color: #9ccf6a; }
.lb small { color: var(--dim); }
.lb b { font-family: var(--pix); }
.keys { display: grid; gap: 6px; margin: 10px 0 12px; text-align: left; }
.keys .k { display: grid; grid-template-columns: 1fr 130px; gap: 10px; align-items: center; font-size: 14px; }
.keys .k button { font-family: var(--pix); font-size: 12px; }
.keys .k button.wait { border-color: var(--acc2); color: var(--acc2); }
#radarBox { cursor: grab; touch-action: none; pointer-events: auto; }
#radarBox.drag { cursor: grabbing; outline: 2px dashed var(--acc2); }
body.touch #bKeys, body.touch #bPauseKeys { display: none; }

/* ---------- Salon et parties publiques ---------- */
.lobcode { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; margin-bottom: 14px; border-radius: 12px; background: rgba(255, 210, 61, 0.08); border: 1px solid rgba(255, 210, 61, 0.4); }
.lobcode b { display: block; font-family: var(--pix); font-size: 34px; letter-spacing: 8px; color: var(--acc2); }
#lobName { flex: 1; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.lobp { display: grid; gap: 6px; }
.lobp .p { display: grid; grid-template-columns: 14px 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 14px; }
.lobp .p i { width: 14px; height: 14px; border-radius: 3px; }
.lobp .p small { color: var(--dim); }
.lobp .p.me { outline: 1px solid var(--acc); }
.pub .g .st { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.pub .g .st.wait { background: rgba(61, 255, 138, 0.15); color: #3dff8a; }
.pub .g .st.live { background: rgba(255, 74, 58, 0.15); color: #ff8a7a; }

#tankPreview { display: block; width: 100%; height: 150px; margin-top: 8px; border-radius: 12px; background: radial-gradient(ellipse at center, #18204a, #0a0e24); }

/* ---------- Souris ---------- */
.mouseset { text-align: left; margin: 4px 0 12px; padding-top: 10px; border-top: 1px solid var(--line); }
body.touch .mouseset, body.touch .mousemenu { display: none !important; }
.mousemenu { font-size: 13px; color: var(--dim); }

/* ---------- Langue ---------- */
.langrow { display: flex; align-items: center; justify-content: center; gap: 8px; margin: -8px 0 14px; font-size: 13px; color: var(--dim); }
.langrow select { width: auto; padding: 6px 10px; font-size: 13px; }

.mmap { display: grid; gap: 6px; margin-top: 8px; }
.mm { display: grid; grid-template-columns: 1fr 150px; gap: 10px; align-items: center; font-size: 13px; }
.mm select { padding: 7px 10px; }

/* ---------- Signaler / exclure ---------- */
.lb { grid-template-columns: 34px 1fr auto auto 26px; }
.lb button.rep { padding: 2px 6px; font-size: 12px; opacity: 0.5; background: none; border-color: transparent; }
.lb button.rep:hover { opacity: 1; }
.lobp .p button.kick { margin-left: 6px; padding: 3px 8px; font-size: 11px; }

/* ---------- Zones de sécurité (encoche, Dynamic Island, barre d'accueil) ---------- */
.screen { padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
