/* Widget « Amis » (salons multijoueur) : charte noir / rouge, ouverture animée */
.room-widget { position: fixed; right: 14px; bottom: 14px; z-index: 45; font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
/* une fenêtre (profil, règles...) est ouverte : le widget ne doit rien recouvrir */
body:has(.modal-backdrop:not([hidden])) .room-widget { display: none; }

.room-fab { position: relative; display: flex; align-items: center; gap: 8px; background: #17171c; color: #fff; border: 1px solid #2f2f38; border-radius: 26px; padding: 5px 14px 5px 5px; font-weight: 700; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.5); cursor: pointer; transition: transform .2s cubic-bezier(.2,.9,.25,1.2), border-color .2s, opacity .2s; }
.room-fab:hover { transform: translateY(-2px); border-color: #e50539; }
.room-fab:active { transform: scale(.96); }
.room-thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: center 40%; border: 2px solid #e50539; }
.room-fab .dot { position: absolute; left: 30px; top: 30px; width: 11px; height: 11px; border-radius: 50%; background: #666; border: 2px solid #17171c; }
.room-fab.online .dot { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.room-fab.ping { animation: roomPing .5s ease-out 3; }
@keyframes roomPing { 50% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(229,5,57,.25); } }
.room-fab b { background: #e50539; color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.room-fab b:empty { display: none; }

.room-backdrop { display: none; }
.room-panel { position: absolute; right: 0; bottom: 56px; width: 320px; max-height: min(72vh, 620px); overflow: auto; overscroll-behavior: contain; background: #15151a; border: 1px solid #2b2b33; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.65); color: #fff;
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(14px) scale(.94); transform-origin: bottom right;
  transition: opacity .22s ease, transform .3s cubic-bezier(.2,.9,.25,1.12), visibility 0s linear .3s; will-change: transform, opacity; }
.room-widget.open .room-panel { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .22s ease, transform .3s cubic-bezier(.2,.9,.25,1.12), visibility 0s; }
.room-grip { display: none; }
.room-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 8px 10px 14px; border-bottom: 1px solid #2b2b33; position: sticky; top: 0; background: #15151a; z-index: 1; font-size: 15px; }
.room-close { width: 36px; height: 36px; padding: 0; border-radius: 50%; color: #a1a1ad; display: inline-flex; align-items: center; justify-content: center; line-height: 0; cursor: pointer; }
.room-close:hover { background: rgba(255,255,255,.08); color: #fff; }
.room-cover { width: 100%; height: 96px; object-fit: cover; object-position: center 40%; display: block; }
.room-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.room-hint { color: #a1a1ad; font-size: 12px; margin: 0; line-height: 1.45; }
.room-notice { color: #74747f; font-size: 11px; line-height: 1.4; margin: 0; }
.room-notice a { color: #ff4d6d; }
.room-invite { font-size: 14px; }
.room-invite b { display: block; font-size: 24px; letter-spacing: 3px; margin-top: 4px; }
.room-btn { background: #26262e; border: 1px solid #3a3a46; color: #fff; border-radius: 10px; padding: 10px 12px; font-weight: 700; font-size: 13px; cursor: pointer; transition: border-color .15s, filter .15s; }
.room-btn:hover { border-color: #5a5a68; }
.room-btn.primary { background: linear-gradient(180deg, #ff2a4f, #c40030); border-color: #ff4d6d; }
.room-btn.primary:hover { filter: brightness(1.08); }
.room-btn.ghost { background: none; border-color: transparent; color: #a1a1ad; }
.room-btn.danger { background: #2a0b12; border-color: #5a1220; color: #ff7171; }
.room-join, .room-chatform { display: flex; gap: 6px; }
.room-join input, .room-chatform input { flex: 1; min-width: 0; background: #0d0d10; border: 1px solid #2b2b33; color: #fff; border-radius: 10px; padding: 10px; font-size: 16px; outline: none; }
.room-join input:focus, .room-chatform input:focus { border-color: #e50539; }
/* carte du salon : code en tuiles, lien, copie animée */
.room-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 14px; border: 1px solid transparent; background: linear-gradient(180deg, #1f1f26, #17171c) padding-box, linear-gradient(135deg, #ff4d6d, #3a3a46 40%, #3a3a46 70%, #ff4d6d) border-box; }
.room-card::after { content: ""; position: absolute; top: 0; bottom: 0; left: -45%; width: 38%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.22), transparent); transform: skewX(-18deg); opacity: 0; pointer-events: none; }
.room-card.flash::after { animation: roomShine .7s ease-out; }
@keyframes roomShine { 0% { left: -45%; opacity: 1; } 100% { left: 120%; opacity: 1; } }
.room-card-top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #a1a1ad; }
.room-live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; background: rgba(34,197,94,.12); color: #7dffa9; letter-spacing: .3px; text-transform: none; }
.room-live i { position: relative; width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }
.room-live i::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: rgba(34,197,94,.6); animation: roomLive 2s ease-out infinite; }
@keyframes roomLive { 0% { transform: scale(1); opacity: 1; } 70%, 100% { transform: scale(2.7); opacity: 0; } }
.room-tiles { display: flex; justify-content: center; gap: 6px; padding: 0; cursor: pointer; }
.room-tiles i { flex: 1 1 0; max-width: 40px; height: 46px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; background: linear-gradient(180deg, #2a2a33, #111115); border: 1px solid #3a3a46; box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 8px rgba(0,0,0,.35); color: #fff; font: 800 20px/1 ui-monospace, Menlo, monospace; font-style: normal; transition: border-color .15s, transform .15s; }
.room-tiles:hover i { border-color: #ff4d6d; }
.room-tiles:active i { transform: translateY(1px); }
.room-card.enter .room-tiles i { animation: roomTile .5s cubic-bezier(.2,1.6,.4,1) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes roomTile { from { opacity: 0; transform: translateY(-14px) rotateX(70deg) scale(.7); } to { opacity: 1; transform: none; } }
.room-card.wave .room-tiles i { animation: roomWave .5s ease-out both; animation-delay: calc(var(--i) * 55ms); }
@keyframes roomWave { 0% { transform: none; } 40% { transform: translateY(-7px); border-color: #22c55e; color: #7dffa9; } 100% { transform: none; } }
.room-url { font: 500 11px/1.2 ui-monospace, Menlo, monospace; color: #8a8a96; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-actions { display: flex; gap: 6px; }
.room-copy { position: relative; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 12px; transition: background .25s, border-color .25s, box-shadow .25s, transform .12s; }
.room-copy:active { transform: scale(.97); }
.room-copy svg { flex: 0 0 auto; transition: transform .25s cubic-bezier(.2,1.6,.4,1), opacity .2s; }
.room-copy .ic-check { position: absolute; left: 50%; margin-left: -52px; transform: scale(0); opacity: 0; }
.room-copy .ic-check path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.room-copy.copied { background: linear-gradient(180deg, #2bd866, #0f9a3c); border-color: #45e37d; box-shadow: 0 8px 22px rgba(25,178,74,.4); animation: roomPop .4s cubic-bezier(.2,1.6,.4,1); }
.room-copy.copied .ic-copy { transform: scale(0) rotate(-40deg); opacity: 0; }
.room-copy.copied .ic-check { position: static; margin: 0 0 0 -26px; transform: scale(1); opacity: 1; }
.room-copy.copied .ic-check path { animation: roomCheck .35s .08s ease-out forwards; }
.room-copy.copied.static { animation: none; }
.room-copy.copied.static .ic-check path { animation: none; stroke-dashoffset: 0; }
@keyframes roomCheck { to { stroke-dashoffset: 0; } }
@keyframes roomPop { 0% { transform: scale(.94); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
.room-sharebtn { flex: 0 0 46px; height: 42px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.room-chip { position: absolute; left: 50%; bottom: 52px; z-index: 2; padding: 5px 11px; border-radius: 999px; background: #19b24a; color: #fff; font-size: 11px; font-weight: 800; white-space: nowrap; box-shadow: 0 6px 16px rgba(25,178,74,.45); pointer-events: none; animation: roomChip 1.5s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes roomChip { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.7); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1); } 70% { opacity: 1; transform: translate(-50%, -22px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -36px) scale(.96); } }
.room-players .room-player.new { animation: roomRow .3s ease-out both; }      /* seulement à l'arrivée d'un joueur : le panneau se reconstruit souvent */
@keyframes roomRow { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.room-status { background: #3a2a0b; color: #ffd166; padding: 6px 10px; border-radius: 8px; font-size: 12px; }
.room-players { display: flex; flex-direction: column; gap: 6px; }
.room-player { display: flex; align-items: center; gap: 8px; background: #1c1c22; padding: 6px 8px; border-radius: 10px; }
.room-player img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.room-player span { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-player small { color: #a1a1ad; font-size: 11px; white-space: nowrap; }
.room-chat { height: 140px; overflow: auto; background: #0d0d10; border-radius: 10px; padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; }
.room-chat b { color: #ff4d6d; }
.room-chat .mine b { color: #4dff8e; }
.room-empty { color: #74747f; margin: auto; font-size: 12px; }

/* mobile : bulle compacte sur le bord droit à mi-hauteur (ne cache plus les boutons du bas), panneau en feuille qui monte */
@media (max-width: 640px) {
  .room-widget { right: 0; bottom: 20%; }
  .room-fab { padding: 4px 6px 4px 4px; border-radius: 26px 0 0 26px; border-right: 0; box-shadow: -4px 6px 18px rgba(0,0,0,.5); }
  .room-fab .lbl { display: none; }
  .room-fab b { margin-right: 2px; }
  .room-widget.open .room-fab { opacity: 0; pointer-events: none; }
  .room-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  .room-widget.open .room-backdrop { opacity: 1; pointer-events: auto; }
  .room-panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 86dvh; border-radius: 20px 20px 0 0; border-bottom: 0; opacity: 1; transform: translateY(104%); transform-origin: bottom center; padding-bottom: env(safe-area-inset-bottom);
    transition: transform .34s cubic-bezier(.2,.85,.2,1), visibility 0s linear .34s; }
  .room-widget.open .room-panel { transform: none; transition: transform .34s cubic-bezier(.2,.85,.2,1), visibility 0s; }
  .room-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: #3a3a46; margin: 8px auto 0; }
  .room-head { border-radius: 20px 20px 0 0; }
  .room-close { width: 44px; height: 44px; }
  .room-cover { height: 84px; }
  .room-btn { padding: 12px; }
}
/* téléphone en paysage : onglet au bord droit, panneau en volet latéral */
@media (orientation: landscape) and (max-height: 520px) {
  .room-widget { right: 0; bottom: 14%; }
  .room-fab { padding: 4px 6px 4px 4px; border-radius: 26px 0 0 26px; border-right: 0; }
  .room-fab .lbl { display: none; }
  .room-thumb { width: 32px; height: 32px; }
  .room-fab .dot { left: 26px; top: 26px; }
  .room-widget.open .room-fab { opacity: 0; pointer-events: none; }
  .room-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .25s ease; }
  .room-widget.open .room-backdrop { opacity: 1; pointer-events: auto; }
  .room-panel { position: fixed; top: 0; right: 0; bottom: 0; left: auto; width: min(340px, 60vw); max-height: none; border-radius: 18px 0 0 18px; border-right: 0; opacity: 1; transform: translateX(104%); transform-origin: right center; padding-right: env(safe-area-inset-right);
    transition: transform .34s cubic-bezier(.2,.85,.2,1), visibility 0s linear .34s; }
  .room-widget.open .room-panel { transform: none; transition: transform .34s cubic-bezier(.2,.85,.2,1), visibility 0s; }
  .room-cover { height: 60px; }
  .room-chat { height: 90px; }
}
/* dans les jeux, la bulle flottante disparaît : le bouton Friends de la barre du haut la remplace */
body:not([data-game="hub"]):not([data-game="legal"]) .room-fab { display: none; }
body:not([data-game="hub"]):not([data-game="legal"]) .room-panel { bottom: 0; }
@media (prefers-reduced-motion: reduce) { .room-panel, .room-backdrop, .room-fab, .room-card *, .room-card::after, .room-chip, .room-player { transition: none !important; animation: none !important; } .room-copy.copied .ic-check path { stroke-dashoffset: 0; } }
.room-chatform input:disabled, .room-chatform button:disabled { opacity: .5; cursor: default; }

/* ---------- invitation à rejoindre le jeu d'un ami : dans le chat, et bandeau qui descend du haut ---------- */
.room-chat .room-inv { display: flex; align-items: center; gap: 8px; margin: 3px 0; padding: 7px 8px; border-radius: 10px; background: linear-gradient(180deg, rgba(229,5,57,.16), rgba(229,5,57,.07)); border: 1px solid rgba(255,77,109,.35); }
.room-inv img { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.room-inv span { flex: 1 1 auto; min-width: 0; color: #e9e9ee; line-height: 1.3; }
.room-chat .room-inv b { color: #fff; }
.room-inv em { flex: 0 0 auto; font-style: normal; font-size: 11px; font-weight: 700; color: #7dffa9; }
.room-joinbtn, .room-toast .rt-join { flex: 0 0 auto; height: 30px; padding: 0 12px; border: 0; border-radius: 9px; background: linear-gradient(180deg, #ff2f55, #c40030); color: #fff; font: 800 12.5px/1 Inter, system-ui, sans-serif; cursor: pointer; box-shadow: 0 6px 16px rgba(229,5,57,.35), inset 0 1px 0 rgba(255,255,255,.3); -webkit-tap-highlight-color: transparent; }
.room-joinbtn:active, .room-toast .rt-join:active { transform: scale(.96); }
.room-toast { position: fixed; z-index: 120; left: 50%; top: calc(8px + env(safe-area-inset-top)); width: min(440px, calc(100vw - 16px)); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 16px; color: #fff; font: 600 13px/1.35 Inter, system-ui, sans-serif;
  border: 1px solid transparent; background: linear-gradient(180deg, #1d1d24, #121216) padding-box, linear-gradient(160deg, rgba(255,77,109,.95), rgba(255,255,255,.1) 45%, rgba(229,5,57,.55)) border-box; box-shadow: 0 18px 44px rgba(0,0,0,.7), 0 0 40px rgba(229,5,57,.18);
  transform: translateX(-50%); animation: roomToastIn .45s cubic-bezier(.2,1.25,.3,1) both; }
.room-toast.out { animation: roomToastOut .3s ease-in forwards; }
@keyframes roomToastIn { from { opacity: 0; transform: translate(-50%, -120%); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes roomToastOut { to { opacity: 0; transform: translate(-50%, -120%); } }
.room-toast > img { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid #e50539; }
.room-toast .rt-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.room-toast small { font-size: 10.5px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: #ff6b85; }
.room-toast .rt-acts { flex: 0 0 auto; display: flex; flex-direction: column; gap: 5px; }
.room-toast .rt-later { height: 26px; padding: 0 10px; border: 1px solid #34343f; border-radius: 9px; background: transparent; color: #b9b9c4; font: 700 11.5px/1 Inter, system-ui, sans-serif; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .room-toast, .room-toast.out, .room-live i::after { animation: none; } }
