* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #12141a; color: #e8eaf0;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; user-select: none; }
#c { display: block; position: fixed; inset: 0; width: 100%; height: 100%; cursor: none; }
#score { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 800;
  background: rgba(10,12,18,.65); padding: 6px 18px; border-radius: 10px; white-space: nowrap; }
#score .sep { opacity: .5; margin: 0 10px; }
#score .meta { display: block; text-align: center; font-size: 11px; font-weight: 500; opacity: .6; }
.t0 { color: #5aa9ff; } .t1 { color: #ff5a5a; } .t2 { color: #5be08a; } .t3 { color: #ffc93d; }
#feed { position: fixed; top: 10px; right: 12px; text-align: right; font-size: 13px; }
#feed div { background: rgba(10,12,18,.6); padding: 3px 9px; border-radius: 6px; margin-bottom: 4px;
  animation: fade 6s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#center { position: fixed; top: 32%; left: 50%; transform: translate(-50%, -50%); font-size: 26px;
  font-weight: 800; text-align: center; text-shadow: 0 2px 8px #000; pointer-events: none; }
#center small { display: block; font-size: 15px; font-weight: 500; opacity: .8; }
#toast { position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%); font-weight: 700;
  color: #ffe08a; text-shadow: 0 2px 6px #000; opacity: 0; transition: opacity .3s; }
#hud { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px;
  align-items: center; background: rgba(10,12,18,.7); padding: 8px 14px; border-radius: 12px; }
#hp { position: relative; width: 160px; height: 18px; background: #2a2e38; border-radius: 9px; overflow: hidden; }
#hpfill { height: 100%; background: linear-gradient(90deg, #3fd47a, #8cf0a8); transition: width .15s; }
#hptxt { position: absolute; inset: 0; text-align: center; font-size: 12px; font-weight: 700; line-height: 18px; }
#slots { display: flex; gap: 6px; }
.slot { width: 52px; height: 40px; border-radius: 8px; background: #23262f; border: 2px solid transparent;
  font-size: 10px; text-align: center; padding-top: 3px; opacity: .35; }
.slot b { display: block; font-size: 15px; }
.slot.own { opacity: 1; } .slot.cur { border-color: #ffe08a; background: #343846; }
#nades { width: 58px; height: 40px; border-radius: 8px; background: #23262f; font-size: 10px; text-align: center;
  padding-top: 3px; color: #9bd06a; }
#nades b { display: block; font-size: 15px; } #nades.empty { opacity: .35; }
#ammo { min-width: 80px; font-size: 20px; font-weight: 800; text-align: right; }
#ammo small { font-size: 12px; opacity: .6; }
#ping { position: fixed; bottom: 6px; right: 10px; font-size: 11px; opacity: .45; }
#flash { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(255,0,0,.8); opacity: 0;
  transition: opacity .25s; }
#lobby { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(40,46,64,.85), rgba(10,11,16,.96)); }
#lobby .box { width: min(420px, 92vw); text-align: center; margin: auto; padding: 10px 0; }   /* margin auto : centré sans couper le haut quand ça déborde */
#lobby h1 { font-size: 52px; letter-spacing: 6px; margin: 0; background: linear-gradient(90deg, #5aa9ff, #ff5a5a);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { opacity: .7; margin-top: 4px; }
#join { display: flex; gap: 8px; margin: 22px 0; }
#join input { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid #3a3f4d; background: #1b1e26;
  color: inherit; font-size: 16px; }
#join button { padding: 12px 16px; border: 0; border-radius: 8px; background: #ffe08a; color: #222;
  font-weight: 800; font-size: 15px; cursor: pointer; }
.help { text-align: left; opacity: .75; padding-left: 18px; }
#status { opacity: .5; font-size: 12px; }

/* ---------- Mode tactile (body.touch, posé par touch.js) ---------- */
html, body { touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#lobby, #lobby * { touch-action: manipulation; }
.touchhelp, #touch, #tbtns, #tmute, #tfull, #rotate, #iosfs { display: none; }
/* iPhone dans Safari : page rendue défilable pour que Safari replie ses barres (glisser vers le haut). */
html.iosplay, html.iosplay body { overflow: visible; height: auto; }
html.iosplay body::after { content: ''; display: block; height: 200vh; }
html.iosplay.swipe, html.iosplay.swipe body { touch-action: pan-y; }
#swipe { display: none; }
html.swipe #swipe { display: flex; position: fixed; inset: 0; z-index: 20; flex-direction: column; align-items: center;
  justify-content: center; gap: 10px; background: rgba(10,11,16,.8); font-size: 22px; font-weight: 800; touch-action: pan-y; }
#swipe .arrow { font-size: 44px; animation: up 1s ease-in-out infinite; }
@keyframes up { 0%, 100% { transform: translateY(10px); } 50% { transform: translateY(-14px); } }
#swipe small { font-size: 13px; font-weight: 500; opacity: .7; max-width: 80vw; text-align: center; }
#swipe button { margin-top: 8px; padding: 8px 14px; border: 0; border-radius: 8px; background: rgba(255,255,255,.15);
  color: #e8eaf0; font: 600 13px system-ui, sans-serif; }
body.touch.playing.ios #tfull { display: block; position: fixed; left: calc(52px + env(safe-area-inset-left)); bottom: 8px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(20,22,30,.55); color: #e8eaf0; font-size: 18px; }
body.ios #iosfs { display: block; font-size: 12px; color: #ffe08a; opacity: .85; }
body.touch.playing.canfs #tfull { display: block; position: fixed; left: calc(52px + env(safe-area-inset-left)); bottom: 8px; z-index: 3;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(20,22,30,.55); color: #e8eaf0; font-size: 18px; }
body.fs #tfull { opacity: .5; }
body.touch .touchhelp { display: block; }
body.touch .keyhelp { display: none; }
body.touch.playing #touch { display: block; position: fixed; inset: 0; }
#touch .stick { display: none; position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); pointer-events: none; }
#touch .knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%;
  background: rgba(255,255,255,.35); }
body.touch.playing #tbtns { display: grid; position: fixed; right: calc(10px + env(safe-area-inset-right)); bottom: 12px;
  grid-template-columns: 62px 62px; gap: 8px; }
#tbtns button { width: 62px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,.18); padding: 0;
  background: rgba(20,22,30,.55); color: #e8eaf0; font: 700 11px system-ui, sans-serif; }
#tbtns button.big { grid-column: span 2; width: 132px; height: 52px; font-size: 14px; background: rgba(255,224,138,.22); }
#tbtns button.on { background: rgba(255,224,138,.6); }
body.touch.playing #tmute { display: block; position: fixed; left: calc(8px + env(safe-area-inset-left)); bottom: 8px;
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(20,22,30,.55); font-size: 16px; }
body.touch #c { cursor: default; }
body.touch #hud { bottom: auto; top: 6px; left: calc(8px + env(safe-area-inset-left)); transform: none; gap: 8px; padding: 5px 8px; }
body.touch #hp { width: 90px; height: 16px; }
body.touch #hptxt { line-height: 16px; font-size: 11px; }
body.touch .slot { width: 40px; height: 34px; font-size: 8px; padding-top: 2px; }
body.touch .slot b { font-size: 12px; }
body.touch .slot.own { pointer-events: auto; }
body.touch #nades { width: 44px; height: 34px; font-size: 8px; padding-top: 2px; }
body.touch #nades b { font-size: 12px; }
body.touch #ammo { min-width: 54px; font-size: 15px; }
body.touch #score { left: auto; right: calc(8px + env(safe-area-inset-right)); transform: none; top: 6px; font-size: 15px; padding: 4px 10px; }
body.touch #score .meta { font-size: 9px; }
body.touch #feed { top: 52px; right: calc(8px + env(safe-area-inset-right)); font-size: 11px; }
body.touch #center { font-size: 20px; }
body.touch #center small { font-size: 13px; }
body.touch #toast { bottom: auto; top: 58px; }
body.touch #ping { bottom: auto; top: 46px; left: calc(10px + env(safe-area-inset-left)); right: auto; }
#hud, #score, #feed, #ping, #toast, #center, #flash { pointer-events: none; }
#rotate { position: fixed; inset: 0; z-index: 10; align-items: center; justify-content: center; flex-direction: column;
  background: rgba(10,11,16,.94); font-size: 22px; font-weight: 800; text-align: center; }
#rotate small { font-size: 14px; font-weight: 500; opacity: .7; margin-top: 6px; }
@media (orientation: portrait) { body.touch.playing #rotate { display: flex; } }
@media (max-height: 500px) {
  #lobby .box { width: min(640px, 92vw); }
  #lobby h1 { font-size: 30px; letter-spacing: 4px; }
  .sub { margin: 0; }
  #join { margin: 10px 0; }
  .help { font-size: 12px; margin: 6px 0; }
}
body.touch.playing #touch { z-index: 1; }
body.touch #hud { z-index: 2; }
#tbtns, #tmute { z-index: 3; }
#lobby { z-index: 5; overflow: auto; }
body.touch #feed div:nth-child(n+3) { display: none; }
body.touch #feed div { padding: 2px 7px; }
#score.melee { font-size: 18px; } #score.melee .sep { margin: 0 6px; }
body.touch #score.melee { font-size: 12px; }
#looks { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.look { display: flex; flex-direction: column; align-items: center; width: 64px; padding: 4px 0 5px; border-radius: 10px;
  border: 2px solid transparent; background: rgba(255,255,255,.05); color: #e8eaf0; font: 600 10px system-ui, sans-serif; cursor: pointer; }
.look canvas { width: 56px; height: 60px; }
.look.on { border-color: #ffe08a; background: rgba(255,224,138,.12); }
@media (max-height: 500px) { #looks { margin-top: 6px; } .look canvas { width: 42px; height: 45px; } .look { width: 52px; } }
/* ---------- Salons ---------- */
#privnote { margin: 12px 0 0; color: #ffe08a; font-size: 13px; }
#privnote:empty { display: none; }
#roombar { display: flex; gap: 12px; align-items: center; justify-content: center; margin: -12px 0 10px; }
#mkpriv { padding: 8px 12px; border: 1px solid #3a3f4d; border-radius: 8px; background: #1b1e26; color: inherit; font: 600 13px system-ui, sans-serif; cursor: pointer; }
#toquick { color: #9fb4d9; font-size: 13px; }
#rooms { text-align: left; font-size: 13px; margin-bottom: 8px; }
#rooms .title { margin: 4px 0; opacity: .6; font-size: 12px; }
#rooms .none { text-align: center; opacity: .5; font-size: 12px; margin: 4px 0; }
#rooms .room { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 8px;
  background: rgba(255,255,255,.05); border-radius: 8px; margin-bottom: 4px; }
#rooms .room small { opacity: .6; }
#rooms .room button { padding: 5px 10px; border: 0; border-radius: 6px; background: #ffe08a; color: #222; font: 700 12px system-ui, sans-serif; cursor: pointer; }
#share { display: none; position: fixed; z-index: 3; left: 12px; bottom: 14px; padding: 7px 12px; border: 0; border-radius: 8px;
  background: rgba(255,224,138,.85); color: #222; font: 700 12px system-ui, sans-serif; cursor: pointer; }
body:not(.playing) #share { display: none !important; }
body.touch #share { left: auto; right: calc(150px + env(safe-area-inset-right)); bottom: 12px; }
#bots { display: none; position: fixed; z-index: 3; left: 12px; bottom: 50px; padding: 7px 12px; border: 0; border-radius: 8px;
  background: rgba(30,34,44,.85); color: #ddd; font: 700 12px system-ui, sans-serif; cursor: pointer; }
body.playing #bots { display: block; }
body.touch #bots { left: auto; right: calc(150px + env(safe-area-inset-right)); bottom: 48px; }
