@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Boogaloo&display=swap');

/* ═══════════════════════════════════════
   VARIABLES
═══════════════════════════════════════ */
:root {
  --bg:        #1a1f35;
  --bg2:       #212840;
  --bg3:       #272e4a;
  --bg4:       #2f3657;
  --card:      #242b47;
  --card2:     #2a3252;

  --yellow:    #f9c234;
  --yellow-dk: #e0a800;
  --cyan:      #00d4ff;
  --cyan-dk:   #00a8cc;
  --green:     #00e599;
  --green-dk:  #00b87a;
  --pink:      #ff4d8d;
  --orange:    #ff7c3a;
  --purple:    #9b5de5;
  --red:       #ff3d5a;

  --text:      #eef1ff;
  --text-muted:#8892b8;
  --text-dim:  #4a5278;

  --border:    rgba(255,255,255,0.06);
  --border-md: rgba(255,255,255,0.11);
  --border-hi: rgba(255,255,255,0.2);

  --font:      'Nunito', system-ui, sans-serif;
  --font-fun:  'Boogaloo', system-ui, sans-serif;

  --r-sm: 12px; --r: 20px; --r-lg: 28px; --r-xl: 36px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 60px rgba(0,0,0,0.6);
  --glow-y: 0 0 24px rgba(249,194,52,0.5);
  --glow-c: 0 0 24px rgba(0,212,255,0.4);
  --glow-g: 0 0 24px rgba(0,229,153,0.4);
}

body.light-mode {
  --bg:        #f0f3ff;
  --bg2:       #e8ecfc;
  --bg3:       #dde3f8;
  --bg4:       #d2daf5;
  --card:      #ffffff;
  --card2:     #f5f7ff;
  --text:      #1a1f35;
  --text-muted:#5a6282;
  --text-dim:  #9aa0be;
  --border:    rgba(0,0,0,0.07);
  --border-md: rgba(0,0,0,0.12);
  --border-hi: rgba(0,0,0,0.2);
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 50px rgba(0,0,0,0.12);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  min-height: 100vh; overflow-x: hidden; line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  -webkit-user-select: none; user-select: none;
}
input, textarea, .chat-messages, .histoire-story-text, .histoire-modal-text {
  -webkit-user-select: text; user-select: text;
}

/* ═══════════════════════════════════════
   BACKGROUND ANIMÉ
═══════════════════════════════════════ */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }

.orb { position: absolute; border-radius: 50%; filter: blur(100px); animation: orbFloat 16s ease-in-out infinite; }
.orb-1 { width: 700px; height: 700px; background: radial-gradient(circle, rgba(155,93,229,0.18), transparent 65%); top: -200px; left: -150px; }
.orb-2 { width: 550px; height: 550px; background: radial-gradient(circle, rgba(0,212,255,0.14), transparent 65%); bottom: -150px; right: -100px; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(249,194,52,0.1), transparent 65%); top: 40%; left: 45%; animation-delay: -13s; }

body.light-mode .orb-1 { background: radial-gradient(circle, rgba(155,93,229,0.07), transparent 65%); }
body.light-mode .orb-2 { background: radial-gradient(circle, rgba(0,212,255,0.06), transparent 65%); }
body.light-mode .orb-3 { background: radial-gradient(circle, rgba(249,194,52,0.05), transparent 65%); }

@keyframes orbFloat {
  0%,100% { transform: translateY(0) scale(1); }
  40%      { transform: translateY(-50px) scale(1.06); }
  70%      { transform: translateY(30px) scale(0.95); }
}

/* Grille dots */
.bg-orbs::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
}
body.light-mode .bg-orbs::before {
  background-image: radial-gradient(circle, rgba(0,0,0,0.06) 1px, transparent 1px);
}

/* ═══════════════════════════════════════
   THEME TOGGLE
═══════════════════════════════════════ */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 1000;
  background: var(--card); border: 1px solid var(--border-md);
  border-radius: 999px; padding: 0.5rem 1rem;
  display: flex; align-items: center; gap: 0.5rem;
  cursor: pointer; color: var(--text-muted);
  font-family: var(--font); font-size: 0.78rem; font-weight: 700;
  transition: all 0.25s; box-shadow: var(--shadow);
}
.theme-toggle:hover { border-color: var(--yellow); color: var(--yellow); box-shadow: var(--glow-y); }
.theme-toggle-icon { font-size: 1rem; }

/* ═══════════════════════════════════════
   LOBBY PAGE
═══════════════════════════════════════ */
.lobby-page { display: flex; flex-direction: column; align-items: center; min-height: 100vh; }

.lobby-container {
  position: relative; z-index: 1;
  width: 100%; max-width: 880px;
  padding: 4rem 1.5rem 3rem;
  display: flex; flex-direction: column; gap: 1.75rem;
}

/* ── Header ── */
.lobby-header { text-align: center; }

.logo-wrap {
  display: inline-flex; align-items: center; gap: 1.1rem;
  background: linear-gradient(135deg, rgba(249,194,52,0.12), rgba(0,212,255,0.08));
  border: 2px solid rgba(249,194,52,0.25);
  border-radius: 999px;
  padding: 0.8rem 2.2rem 0.8rem 1.2rem;
  margin-bottom: 1.2rem;
  animation: logoIn 0.8s cubic-bezier(0.34,1.56,0.64,1) both;
  position: relative; overflow: hidden;
}
.logo-wrap::after {
  content: '';
  position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: logoShine 4s ease-in-out infinite;
}
@keyframes logoShine { 0%{left:-100%} 50%,100%{left:100%} }
@keyframes logoIn { from{opacity:0;transform:scale(0.7) translateY(-20px)} to{opacity:1;transform:scale(1) translateY(0)} }

.logo-icon-wrap { font-size: 2.8rem; animation: diceSpin 6s ease-in-out infinite; }
@keyframes diceSpin {
  0%,80%,100% { transform: rotate(0deg) scale(1); }
  88%          { transform: rotate(30deg) scale(1.15); }
  94%          { transform: rotate(-15deg) scale(0.92); }
}

.logo-text-wrap { display: flex; align-items: baseline; gap: 0.6rem; }
.logo-text {
  font-family: var(--font-fun);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  letter-spacing: 0.02em;
  color: var(--text); line-height: 1;
}
.logo-text .accent {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 12px rgba(249,194,52,0.4));
}
.logo-badge {
  font-size: 0.55rem; font-weight: 900; letter-spacing: 0.2em;
  color: var(--cyan); background: rgba(0,212,255,0.12);
  border: 1px solid rgba(0,212,255,0.3);
  border-radius: 999px; padding: 0.15rem 0.6rem; text-transform: uppercase;
  animation: badgeBlink 3s ease-in-out infinite;
}
@keyframes badgeBlink { 0%,100%{opacity:1} 50%{opacity:0.5} }

.tagline {
  color: var(--text-muted); font-size: 0.9rem; font-weight: 600;
  animation: fadeUp 0.6s ease 0.4s both;
}
@keyframes fadeUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  padding: 2rem;
  position: relative; overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: cardIn 0.5s ease both;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--yellow), var(--cyan), var(--green));
  opacity: 0; transition: opacity 0.3s;
}
.card:hover::before { opacity: 1; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-hi); }
@keyframes cardIn { from{opacity:0;transform:translateY(24px) scale(0.97)} to{opacity:1;transform:translateY(0) scale(1)} }

.card-icon { font-size: 2rem; margin-bottom: 0.7rem; display: block; animation: iconBounce 3s ease-in-out infinite; }
@keyframes iconBounce { 0%,70%,100%{transform:translateY(0)} 85%{transform:translateY(-6px)} }

.card-title {
  font-family: var(--font-fun);
  font-size: 1.1rem; letter-spacing: 0.03em;
  color: var(--text); margin-bottom: 0.5rem;
}
.card-desc { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 1.4rem; line-height: 1.6; }

.actions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 600px) { .actions-grid { grid-template-columns: 1fr; } }

/* ── Inputs ── */
.input-group { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 1.4rem; }
.input-group label {
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
}
.input-group input, .input-group select, .code-input {
  background: var(--bg3); border: 2px solid var(--border-md);
  border-radius: var(--r-sm); color: var(--text);
  font-family: var(--font); font-size: 1rem; font-weight: 600;
  padding: 0.8rem 1.2rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s; width: 100%;
}
.input-group input:focus, .input-group select:focus, .code-input:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(0,212,255,0.15);
}
.code-input {
  text-transform: uppercase; letter-spacing: 0.35em;
  font-size: 1.3rem; font-weight: 900; text-align: center;
  font-family: var(--font-fun);
}
.input-group select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892b8' fill='none' stroke-width='2.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 1.1rem center;
  padding-right: 2.8rem;
}
.input-hint { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  font-family: var(--font); font-size: 1rem; font-weight: 800;
  border: none; border-radius: var(--r);
  padding: 0.9rem 2rem; cursor: pointer;
  transition: all 0.2s; width: 100%;
  position: relative; overflow: hidden; letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #1a1a1a;
  box-shadow: 0 6px 28px rgba(249,194,52,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 10px 36px rgba(249,194,52,0.6);
  transform: translateY(-3px) scale(1.01);
}

.btn-secondary {
  background: var(--bg3); color: var(--text);
  border: 2px solid var(--border-md);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--cyan); color: var(--cyan);
  box-shadow: 0 4px 20px rgba(0,212,255,0.2);
  transform: translateY(-2px);
}

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 2px solid var(--border); font-weight: 700; font-size: 0.88rem;
}
.btn-ghost:hover { border-color: var(--border-hi); color: var(--text); }

.btn-sm { width: auto; padding: 0.45rem 1.2rem; font-size: 0.82rem; }

.btn-kick {
  margin-left: auto; background: transparent;
  border: 1px solid rgba(255,61,90,0.2); border-radius: 8px;
  color: rgba(255,61,90,0.5); cursor: pointer;
  font-size: 0.65rem; font-weight: 800; padding: 0.15rem 0.55rem;
  transition: all 0.2s; font-family: var(--font);
}
.btn-kick:hover { background: rgba(255,61,90,0.12); border-color: var(--red); color: var(--red); }

/* ── Waiting Room ── */
.waiting-card { animation-delay: 0.1s; }
.waiting-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.room-meta { font-size: 0.88rem; color: var(--text-muted); margin-top: 0.2rem; font-weight: 600; }
.room-meta strong { color: var(--cyan); }
.room-code-display { display: flex; align-items: center; gap: 0.7rem; }
.room-code-label { font-size: 0.62rem; color: var(--text-dim); font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; }
.room-code-value {
  font-family: var(--font-fun); font-size: 2rem; letter-spacing: 0.32em;
  background: linear-gradient(135deg, var(--yellow), var(--cyan));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 10px rgba(249,194,52,0.4));
  animation: codeGlow 3s ease-in-out infinite;
}
@keyframes codeGlow {
  0%,100% { filter: drop-shadow(0 0 8px rgba(249,194,52,0.3)); }
  50%      { filter: drop-shadow(0 0 20px rgba(0,212,255,0.5)); }
}
.btn-copy {
  background: var(--bg3); border: 1px solid var(--border-md); border-radius: 10px;
  color: var(--text-muted); cursor: pointer; padding: 0.5rem 0.65rem;
  transition: all 0.2s; display: flex; align-items: center;
}
.btn-copy:hover { color: var(--yellow); border-color: var(--yellow); transform: scale(1.08); }

.players-list-section h3 {
  font-family: var(--font-fun); font-size: 0.85rem; letter-spacing: 0.08em;
  color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.count-badge {
  background: var(--yellow); color: #1a1a1a;
  font-size: 0.65rem; font-weight: 900;
  border-radius: 999px; padding: 0.1rem 0.55rem;
  -webkit-text-fill-color: #1a1a1a;
}

.players-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1.4rem; }
.players-list li {
  display: flex; align-items: center; gap: 0.8rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 0.7rem 1.1rem;
  font-size: 0.92rem; font-weight: 700;
  transition: all 0.2s;
  animation: playerIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes playerIn { from{opacity:0;transform:translateX(-14px) scale(0.95)} to{opacity:1;transform:translateX(0) scale(1)} }
.players-list li.is-you { border-color: rgba(0,212,255,0.35); background: rgba(0,212,255,0.07); }
.players-list li.is-host { border-color: rgba(249,194,52,0.25); }

.player-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); flex-shrink: 0; box-shadow: 0 0 10px rgba(0,229,153,0.7); animation: dotPulse 2s ease-in-out infinite; }
@keyframes dotPulse { 0%,100%{box-shadow:0 0 6px rgba(0,229,153,0.5)} 50%{box-shadow:0 0 16px rgba(0,229,153,0.9)} }
.player-dot.offline { background: var(--text-dim); box-shadow: none; animation: none; }

.player-badge { margin-left: auto; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.07em; border-radius: 999px; padding: 0.18rem 0.7rem; }
.badge-host { background: rgba(249,194,52,0.15); color: var(--yellow); border: 1px solid rgba(249,194,52,0.35); }
.badge-you  { background: rgba(0,212,255,0.12); color: var(--cyan); border: 1px solid rgba(0,212,255,0.3); }

.host-game-change { background: var(--bg3); border: 1px solid var(--border-md); border-radius: var(--r-sm); padding: 1.1rem; margin-bottom: 1rem; }
.host-game-change label { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 0.5rem; }
.host-game-change select { width: 100%; background: var(--bg2); border: 1px solid var(--border-md); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 0.9rem; font-weight: 700; padding: 0.65rem 0.9rem; outline: none; cursor: pointer; appearance: none; margin-bottom: 0.75rem; transition: border-color 0.2s; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238892b8' fill='none' stroke-width='2.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.9rem center; padding-right: 2.2rem; }
.host-game-change select:focus { border-color: var(--cyan); }

#host-controls, #guest-waiting { text-align: center; padding: 0.5rem 0; }
.host-hint { font-size: 0.87rem; color: var(--text-muted); margin-bottom: 1rem; font-weight: 700; }

.waiting-pulse { display: flex; align-items: center; justify-content: center; gap: 0.7rem; font-size: 0.9rem; color: var(--text-muted); padding: 0.75rem; font-weight: 700; }
.pulse-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); animation: pulseAnim 1.6s ease-in-out infinite; }
@keyframes pulseAnim { 0%,100%{opacity:1;transform:scale(1);box-shadow:0 0 0 0 rgba(0,212,255,0.6)} 50%{opacity:0.7;transform:scale(0.88);box-shadow:0 0 0 10px rgba(0,212,255,0)} }

#leave-room-btn { margin-top: 1rem; }
.waiting-chat { margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════
   GAME PAGE
═══════════════════════════════════════ */
.game-page { min-height: 100vh; }

/* Layout : [main] [sidebar droite] — 2 colonnes sur PC */
.game-layout { display: grid; grid-template-columns: 1fr 270px; min-height: 100vh; }
@media (max-width: 700px) { .game-layout { grid-template-columns: 1fr; } }

/* ── Sidebar droite masquée sur mobile ── */
@media (max-width: 700px) { .game-sidebar { display: none; } }

/* ── Bouton chat flottant (FAB) — visible uniquement mobile ── */
.chat-fab {
  display: none;
  position: fixed; top: 0.6rem; left: 0.6rem; z-index: 200;
  background: var(--card); border: 1px solid var(--border-md);
  border-radius: 22px; padding: 0.4rem 0.85rem;
  font-size: 1rem; cursor: pointer; color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  display: none; align-items: center; gap: 0.4rem;
  transition: all 0.2s;
}
.chat-fab:hover { border-color: var(--cyan); }
@media (max-width: 700px) { .chat-fab { display: flex; } }

/* Badge notification */
.chat-notif-badge {
  background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 800;
  border-radius: 999px; padding: 0.05rem 0.38rem; min-width: 16px; text-align: center;
  line-height: 1.4;
}

/* ── Overlay chat mobile ── */
.chat-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.45); backdrop-filter: blur(2px);
}
.chat-overlay.open { display: block; }
.chat-overlay-panel {
  position: absolute; top: 3.2rem; left: 0.6rem; right: 0.6rem;
  max-height: 55vh;
  background: var(--card); border: 1px solid var(--border-md);
  border-radius: var(--r); display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.chat-overlay-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 800; color: var(--text-muted); flex-shrink: 0;
}
.chat-overlay .chat-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 0.35rem; padding: 0.6rem 0.85rem; min-height: 0;
}
.chat-overlay .chat-input-row {
  padding: 0.55rem 0.75rem; border-top: 1px solid var(--border); flex-shrink: 0;
}

/* ── Chat dans sidebar (PC) ── */
.chat-section-sidebar {
  display: flex; flex-direction: column; flex: 1; padding: 0.85rem 1.1rem;
  min-height: 0; overflow: hidden; border-top: 1px solid var(--border);
}
.chat-section-sidebar .chat-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 0.38rem; margin: 0.5rem 0 0.5rem; padding-right: 0.1rem; min-height: 80px;
}
@media (max-width: 700px) { .chat-section-sidebar { display: none !important; } }
.chat-typing { font-size: 0.72rem; color: var(--text-dim); font-style: italic; min-height: 1.1rem; margin-bottom: 0.35rem; }

/* ── Sidebar ── */
.game-sidebar {
  background: var(--card); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  position: relative; z-index: 1;
}

.sidebar-brand {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.1rem 0.9rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(249,194,52,0.06), rgba(0,212,255,0.04));
}
.sidebar-logo { font-family: var(--font-fun); font-size: 1.05rem; letter-spacing: 0.03em; color: var(--text); }

.btn-icon-only {
  background: var(--bg3); border: 1px solid var(--border-md); border-radius: 10px;
  color: var(--text-muted); cursor: pointer; padding: 0.45rem;
  display: flex; align-items: center; transition: all 0.2s;
}
.btn-icon-only:hover { color: var(--red); border-color: rgba(255,61,90,0.4); background: rgba(255,61,90,0.1); }

.sidebar-room { padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-room-code { font-family: var(--font-fun); font-size: 1.2rem; letter-spacing: 0.22em; background: linear-gradient(135deg, var(--yellow), var(--cyan)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.sidebar-game-name { font-size: 0.75rem; color: var(--text-muted); font-weight: 700; margin-top: 0.15rem; }

.sidebar-host-controls { padding: 0.8rem 1.1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-host-controls .sidebar-section-label { margin-bottom: 0.6rem; }
.sidebar-host-controls select { width: 100%; background: var(--bg3); border: 1px solid var(--border-md); border-radius: 8px; color: var(--text); font-family: var(--font); font-size: 0.8rem; font-weight: 700; padding: 0.48rem 0.7rem; outline: none; cursor: pointer; appearance: none; margin-bottom: 0.5rem; transition: border-color 0.2s; }
.sidebar-host-controls select:focus { border-color: var(--cyan); }
.sidebar-host-controls .btn-sm { width: 100%; font-size: 0.76rem; padding: 0.48rem 0.8rem; }

.sidebar-section { padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-section-label { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 0.75rem; }

.players-list.compact { gap: 0.32rem; margin-bottom: 0; }
.players-list.compact li { padding: 0.45rem 0.8rem; font-size: 0.83rem; }

/* Turn indicator */
.turn-indicator {
  margin: 0.9rem 1.1rem; background: var(--bg3);
  border: 1px solid var(--border-md); border-radius: var(--r-sm);
  padding: 0.9rem 1rem; text-align: center; flex-shrink: 0; transition: all 0.4s;
}
.turn-indicator.your-turn {
  background: linear-gradient(135deg, rgba(0,229,153,0.12), rgba(0,229,153,0.04));
  border-color: rgba(0,229,153,0.4);
  animation: yourTurn 2s ease-in-out infinite;
}
@keyframes yourTurn { 0%,100%{box-shadow:0 0 0 rgba(0,229,153,0)} 50%{box-shadow:0 0 28px rgba(0,229,153,0.3)} }
.turn-label { font-size: 0.58rem; letter-spacing: 0.18em; color: var(--text-dim); text-transform: uppercase; font-weight: 800; }
.turn-player { font-size: 1rem; font-weight: 800; color: var(--text); margin: 0.15rem 0; }
.turn-symbol { font-size: 1.5rem; line-height: 1; }

/* Chat */
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.38rem; margin-bottom: 0.75rem; padding-right: 0.15rem; }
.chat-msg { font-size: 0.8rem; line-height: 1.5; padding: 0.4rem 0.75rem; border-radius: 10px; background: var(--bg3); border: 1px solid var(--border); word-break: break-word; animation: msgIn 0.2s ease; font-weight: 600; }
@keyframes msgIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.chat-msg.is-system { background: transparent; border: none; color: var(--text-dim); font-style: italic; text-align: center; font-size: 0.73rem; }
.msg-author { font-weight: 800; color: var(--cyan); margin-right: 0.4rem; }
.chat-input-row { display: flex; gap: 0.45rem; flex-shrink: 0; }
.chat-input-row input { flex: 1; background: var(--bg3); border: 1px solid var(--border-md); border-radius: 10px; color: var(--text); font-family: var(--font); font-size: 0.83rem; font-weight: 600; padding: 0.55rem 0.85rem; outline: none; transition: border-color 0.2s; }
.chat-input-row input:focus { border-color: var(--cyan); }
.btn-send { background: linear-gradient(135deg, var(--cyan), var(--purple)); border: none; border-radius: 10px; color: white; cursor: pointer; padding: 0.55rem 0.75rem; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.btn-send:hover { filter: brightness(1.18); transform: scale(1.08); }

/* Historique sidebar */
.history-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 140px; overflow-y: auto; }
.history-item { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; padding: 0.25rem 0.5rem; background: var(--bg3); border-radius: 6px; border-left: 2px solid var(--cyan); line-height: 1.4; }

/* Histoire actions */
.histoire-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; margin-top: 0.75rem; }

/* ═══════════════════════════════════════
   GAME MAIN
═══════════════════════════════════════ */
.game-main { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; padding: 2rem 1.5rem; overflow-y: auto; }

.game-topbar {
  width: 100%; max-width: 600px;
  background: var(--card); border: 1px solid var(--border-md);
  border-radius: var(--r); padding: 0.6rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  font-size: 0.87rem; font-weight: 700;
  color: var(--text-muted); margin-bottom: 2rem;
}
.btn-rules {
  background: transparent; border: 1px solid var(--border-md);
  border-radius: 999px; color: var(--text-muted);
  font-family: var(--font); font-size: 0.75rem; font-weight: 800;
  padding: 0.3rem 0.85rem; cursor: pointer; white-space: nowrap;
  transition: all 0.2s; flex-shrink: 0;
}
.btn-rules:hover { border-color: var(--cyan); color: var(--cyan); }

/* ── Rules modal ── */
.rules-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 1.5rem;
}
.rules-overlay.open { display: flex; }
.rules-panel {
  background: var(--card2); border: 1px solid var(--border-hi);
  border-radius: var(--r-xl); width: 100%; max-width: 520px;
  max-height: 80vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: var(--shadow-lg);
  animation: modalPop 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.rules-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.rules-title { font-family: var(--font-fun); font-size: 1.1rem; color: var(--text); letter-spacing: 0.03em; }
.rules-body {
  overflow-y: auto; padding: 1.3rem 1.4rem;
  display: flex; flex-direction: column; gap: 1rem;
  font-size: 0.88rem; line-height: 1.7; color: var(--text-muted);
  font-weight: 600; -webkit-user-select: text; user-select: text;
}
.rules-body h3 {
  font-family: var(--font-fun); font-size: 0.95rem; color: var(--cyan);
  letter-spacing: 0.05em; margin-bottom: -0.4rem;
}
.rules-body p { color: var(--text-muted); }
.rules-body strong { color: var(--text); font-weight: 800; }
.rules-body .rules-step {
  display: flex; gap: 0.8rem; align-items: flex-start;
  background: var(--bg3); border-radius: var(--r-sm);
  padding: 0.65rem 0.9rem; border: 1px solid var(--border);
}
.rules-step-num {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: #1a1a1a; font-weight: 900; font-size: 0.72rem;
  border-radius: 999px; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 0.1rem;
}

.game-area { width: 100%; max-width: 600px; display: flex; flex-direction: column; align-items: center; gap: 1.4rem; animation: gameIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes gameIn { from{opacity:0;transform:translateY(28px) scale(0.96)} to{opacity:1;transform:translateY(0) scale(1)} }

.game-title { font-family: var(--font-fun); font-size: 1.5rem; letter-spacing: 0.04em; color: var(--text); text-align: center; display: flex; align-items: center; gap: 0.6rem; }
.game-title-icon { font-size: 1.6rem; animation: iconBounce 3s ease-in-out infinite; }

/* Score Board */
.score-board {
  display: flex; align-items: center; gap: 1.8rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 1.2rem 2.5rem;
  width: 100%; justify-content: center; position: relative; overflow: hidden;
}
.score-board::before { content:''; position:absolute; bottom:0; left:0; right:0; height:3px; background:linear-gradient(90deg,var(--yellow),var(--cyan),var(--green),var(--yellow)); background-size:200% 100%; animation:scoreBar 3s linear infinite; }
@keyframes scoreBar { 0%{background-position:0% 0} 100%{background-position:200% 0} }
.score-item { display: flex; align-items: center; gap: 0.7rem; }
.score-p1 { flex-direction: row; }
.score-p2 { flex-direction: row-reverse; }
.score-player { font-weight: 800; max-width: 95px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-symbol { font-size: 1.4rem; }
.score-value { color: var(--yellow); font-size: 1.8rem; font-weight: 900; min-width: 1.5ch; text-align: center; font-family: var(--font-fun); filter: drop-shadow(0 0 8px rgba(249,194,52,0.5)); }
.score-vs { color: var(--text-dim); font-size: 0.75rem; font-weight: 900; letter-spacing: 0.15em; }
.spectator-badge { background: rgba(255,255,255,0.04); border: 1px dashed var(--border-md); border-radius: 999px; padding: 0.4rem 1.2rem; font-size: 0.82rem; color: var(--text-muted); font-weight: 700; }

/* ═══════════════════════════════════════
   TIC-TAC-TOE
═══════════════════════════════════════ */
.ttt-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(88vw, 350px); background: var(--card); padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border-md); box-shadow: var(--shadow); }
.ttt-cell { aspect-ratio: 1; background: var(--bg3); border: 2px solid var(--border-md); border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: clamp(2.4rem, 7vw, 3.5rem); font-weight: 900; cursor: pointer; transition: all 0.18s; user-select: none; }
.ttt-cell:hover:not(.taken):not(.disabled) { background: rgba(0,212,255,0.1); border-color: var(--cyan); transform: scale(1.07); box-shadow: 0 4px 20px rgba(0,212,255,0.25); }
.ttt-cell.taken { cursor: default; }
.ttt-cell.X { color: var(--cyan); text-shadow: 0 0 28px rgba(0,212,255,0.7); animation: cellPop 0.3s cubic-bezier(0.34,1.56,0.64,1); }
.ttt-cell.O { color: var(--yellow); text-shadow: 0 0 28px rgba(249,194,52,0.7); animation: cellPop 0.3s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes cellPop { from{transform:scale(0) rotate(-20deg);opacity:0} to{transform:scale(1) rotate(0);opacity:1} }
.ttt-cell.winning { background: rgba(0,229,153,0.14); border-color: var(--green); animation: winPop 0.4s cubic-bezier(0.34,1.56,0.64,1) both, winGlow 1.5s ease-in-out infinite; }
@keyframes winPop { from{transform:scale(0.85)} to{transform:scale(1.08)} }
@keyframes winGlow { 0%,100%{box-shadow:0 0 0 rgba(0,229,153,0)} 50%{box-shadow:0 0 24px rgba(0,229,153,0.45)} }
.ttt-cell.disabled { cursor: not-allowed; opacity: 0.45; }

/* ═══════════════════════════════════════
   CONNECT 4
═══════════════════════════════════════ */
.c4-column-indicators { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; width: min(93vw, 450px); }
.c4-col-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 0.38rem; transition: color 0.15s, transform 0.2s; text-align: center; }
.c4-col-btn:hover:not(:disabled) { color: var(--yellow); transform: translateY(-6px); filter: drop-shadow(0 4px 8px rgba(249,194,52,0.5)); }
.c4-col-btn:disabled { cursor: not-allowed; opacity: 0.2; }
.c4-board { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; background: var(--card); border: 1px solid var(--border-md); border-radius: var(--r-lg); padding: 14px; width: min(93vw, 450px); box-shadow: var(--shadow); }
.c4-cell { aspect-ratio: 1; border-radius: 50%; background: var(--bg3); border: 2px solid rgba(255,255,255,0.05); transition: all 0.25s; }
.c4-cell.red { background: var(--pink); box-shadow: 0 0 16px rgba(255,77,141,0.65); border-color: var(--pink); animation: discDrop 0.38s cubic-bezier(0.34,1.3,0.64,1); }
.c4-cell.yellow { background: var(--yellow); box-shadow: 0 0 16px rgba(249,194,52,0.65); border-color: var(--yellow); animation: discDrop 0.38s cubic-bezier(0.34,1.3,0.64,1); }
@keyframes discDrop { from{transform:scale(0.4);opacity:0.4} to{transform:scale(1);opacity:1} }
.c4-cell.winning { animation: c4Flash 0.55s ease-in-out infinite alternate; }
@keyframes c4Flash { from{filter:brightness(1);transform:scale(1)} to{filter:brightness(2) saturate(1.5);transform:scale(1.08)} }
.c4-disc { font-size: 1.3rem; }
.disc-red { color: var(--pink); }
.disc-yellow { color: var(--yellow); }

/* ═══════════════════════════════════════
   QUIZ
═══════════════════════════════════════ */
.quiz-round-badge { background: var(--bg3); border: 2px solid var(--border-md); border-radius: 999px; padding: 0.38rem 1.3rem; font-size: 0.82rem; font-weight: 800; color: var(--text-muted); }
.quiz-question-card { background: var(--card); border: 1px solid var(--border-md); border-radius: var(--r-lg); padding: 1.8rem 2.2rem; text-align: center; width: 100%; box-shadow: var(--shadow); animation: questionSlide 0.4s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes questionSlide { from{opacity:0;transform:translateY(-14px)} to{opacity:1;transform:translateY(0)} }
.quiz-question-text { font-size: clamp(1.05rem, 2.5vw, 1.25rem); font-weight: 800; line-height: 1.65; }
.quiz-answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; width: 100%; }
.quiz-answer-btn { background: var(--card); border: 2px solid var(--border-md); border-radius: var(--r-sm); color: var(--text); cursor: pointer; font-family: var(--font); font-size: 0.9rem; font-weight: 700; padding: 1rem 1.2rem; text-align: left; transition: all 0.18s; line-height: 1.4; }
.quiz-answer-btn:hover:not(:disabled) { border-color: var(--cyan); background: rgba(0,212,255,0.08); transform: translateY(-2px); box-shadow: 0 4px 18px rgba(0,212,255,0.2); }
.quiz-answer-btn.correct { border-color: var(--green); background: rgba(0,229,153,0.12); color: var(--green); font-weight: 800; animation: correctPop 0.4s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes correctPop { from{transform:scale(0.93)} to{transform:scale(1)} }
.quiz-answer-btn.wrong { border-color: var(--red); background: rgba(255,61,90,0.08); color: var(--red); }
.quiz-answer-btn.selected { border-color: var(--cyan); background: rgba(0,212,255,0.1); }
.quiz-answer-btn:disabled { cursor: not-allowed; }
.quiz-waiting-answers { font-size: 0.84rem; color: var(--text-muted); text-align: center; font-weight: 700; }
.quiz-answered-msg { color: var(--green); font-size: 0.9rem; font-weight: 800; text-align: center; padding: 0.5rem; }
.quiz-scoreboard { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 1.2rem 1.4rem; }
.quiz-scoreboard h3 { font-size: 0.68rem; letter-spacing: 0.2em; color: var(--text-muted); text-transform: uppercase; font-weight: 800; margin-bottom: 0.85rem; }
#quiz-scores-list { list-style: none; display: flex; flex-direction: column; gap: 0.45rem; }
#quiz-scores-list li { display: flex; justify-content: space-between; align-items: center; font-size: 0.88rem; font-weight: 700; padding: 0.48rem 0.85rem; border-radius: 10px; background: var(--bg3); border: 1px solid var(--border); }
#quiz-scores-list li:first-child { border-color: rgba(249,194,52,0.35); background: rgba(249,194,52,0.06); }
#quiz-scores-list li .qs-score { color: var(--yellow); font-weight: 900; font-size: 1rem; font-family: var(--font-fun); filter: drop-shadow(0 0 6px rgba(249,194,52,0.4)); }

/* ═══════════════════════════════════════
   HISTOIRE
═══════════════════════════════════════ */
.histoire-story-card { width: 100%; background: var(--card); border: 1px solid var(--border-md); border-radius: var(--r-lg); padding: 1.6rem; min-height: 155px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.histoire-story-card::before { content:'📖'; position:absolute; top:1rem; right:1.4rem; font-size:1.8rem; opacity:0.1; animation:bookFloat 4s ease-in-out infinite; }
@keyframes bookFloat { 0%,100%{transform:translateY(0) rotate(-5deg)} 50%{transform:translateY(-7px) rotate(5deg)} }
.histoire-story-text { font-size: 0.98rem; line-height: 1.95; color: var(--text); white-space: pre-wrap; word-break: break-word; font-weight: 600; }
.histoire-story-text em { color: var(--text-muted); }
.histoire-input-area { width: 100%; display: flex; flex-direction: column; gap: 0.7rem; }
.histoire-prompt { font-size: 0.87rem; font-weight: 800; color: var(--cyan); text-align: center; padding: 0.4rem; animation: promptPulse 2s ease-in-out infinite; }
@keyframes promptPulse { 0%,100%{opacity:1} 50%{opacity:0.65} }
.histoire-input-area textarea { width: 100%; background: var(--bg3); border: 2px solid var(--border-md); border-radius: var(--r-sm); color: var(--text); font-family: var(--font); font-size: 0.97rem; font-weight: 600; padding: 0.95rem 1.15rem; outline: none; resize: none; transition: border-color 0.2s, box-shadow 0.2s; line-height: 1.65; -webkit-user-select: text; user-select: text; }
.histoire-input-area textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(0,212,255,0.15); }
.histoire-counter { font-size: 0.73rem; color: var(--text-dim); text-align: right; font-weight: 700; }
.histoire-waiting { display: flex; align-items: center; gap: 0.7rem; font-size: 0.9rem; color: var(--text-muted); padding: 0.6rem; font-weight: 700; }
.histoire-spectator { background: rgba(255,255,255,0.04); border: 1px dashed var(--border-md); border-radius: 999px; padding: 0.4rem 1.2rem; font-size: 0.82rem; color: var(--text-muted); font-weight: 700; }
.histoire-scoreboard { width: 100%; }
.histoire-players-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.histoire-players-list li { display: flex; align-items: center; gap: 0.7rem; background: var(--bg3); border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.85rem; font-size: 0.87rem; font-weight: 700; transition: all 0.2s; }
.histoire-players-list li.current-turn { border-color: rgba(0,212,255,0.4); background: rgba(0,212,255,0.08); animation: turnPulse 2s ease-in-out infinite; }
@keyframes turnPulse { 0%,100%{box-shadow:0 0 0 rgba(0,212,255,0)} 50%{box-shadow:0 0 14px rgba(0,212,255,0.25)} }
.histoire-full-modal { position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,0.82); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center; padding: 2rem; animation: modalFade 0.22s ease; }
@keyframes modalFade { from{opacity:0} to{opacity:1} }
.histoire-modal-inner { background: var(--card2); border: 1px solid var(--border-hi); border-radius: var(--r-xl); padding: 2.2rem; max-width: 600px; width: 100%; max-height: 80vh; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; animation: modalPop 0.38s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes modalPop { from{transform:scale(0.9) translateY(24px);opacity:0} to{transform:scale(1) translateY(0);opacity:1} }
.histoire-modal-inner h3 { font-family: var(--font-fun); font-size: 1.2rem; }
.histoire-modal-text { font-size: 0.97rem; line-height: 1.95; color: var(--text); white-space: pre-wrap; flex: 1; font-weight: 600; -webkit-user-select: text; user-select: text; }

/* ═══════════════════════════════════════
   GAME RESULT
═══════════════════════════════════════ */
.game-result {
  text-align: center; width: 100%;
  background: var(--card); border: 2px solid var(--border-md);
  border-radius: var(--r-xl); padding: 2.5rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.4rem;
  animation: resultPop 0.6s cubic-bezier(0.34,1.56,0.64,1) both;
  position: relative; overflow: hidden;
}
.game-result::before { content:''; position:absolute; inset:0; background:radial-gradient(ellipse at top, rgba(249,194,52,0.08), transparent 55%); pointer-events:none; }
.game-result::after { content:''; position:absolute; top:0; left:0; right:0; height:4px; background:linear-gradient(90deg,var(--yellow),var(--cyan),var(--green),var(--pink)); }
@keyframes resultPop { from{opacity:0;transform:scale(0.82) translateY(28px)} to{opacity:1;transform:scale(1) translateY(0)} }
.result-emoji { font-size: 3.8rem; animation: emojiIn 0.7s cubic-bezier(0.34,1.56,0.64,1) both, emojiFloat 3s ease-in-out 0.7s infinite; }
@keyframes emojiIn { from{transform:scale(0) rotate(-30deg)} to{transform:scale(1) rotate(0)} }
@keyframes emojiFloat { 0%,100%{transform:translateY(0) scale(1)} 50%{transform:translateY(-10px) scale(1.05)} }
.result-text { font-family: var(--font-fun); font-size: clamp(1.3rem, 4.5vw, 1.9rem); color: var(--text); line-height: 1.4; letter-spacing: 0.02em; }

/* ═══════════════════════════════════════
   CONFETTI
═══════════════════════════════════════ */
.confetti-piece { position: fixed; top: -10px; pointer-events: none; z-index: 9998; border-radius: 2px; animation: confettiFall linear forwards; }
@keyframes confettiFall { 0%{transform:translateY(0) rotate(0deg);opacity:1} 80%{opacity:1} 100%{transform:translateY(100vh) rotate(720deg);opacity:0} }

/* ═══════════════════════════════════════
   TOAST
═══════════════════════════════════════ */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.6rem; pointer-events: none; }
.toast { background: var(--card2); border-radius: var(--r-sm); border-left: 4px solid var(--cyan); padding: 0.85rem 1.3rem; font-size: 0.85rem; font-weight: 700; color: var(--text); box-shadow: var(--shadow); animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both; max-width: 300px; }
.toast.error   { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--yellow); }
@keyframes toastIn { from{opacity:0;transform:translateX(28px) scale(0.9)} to{opacity:1;transform:translateX(0) scale(1)} }

/* ═══════════════════════════════════════
   FOOTER
═══════════════════════════════════════ */
.lobby-footer { position: relative; z-index: 1; text-align: center; padding: 2rem 1.5rem; font-size: 0.73rem; color: var(--text-dim); font-weight: 700; letter-spacing: 0.07em; }

/* ═══════════════════════════════════════
   NOUVEAUX JEUX
═══════════════════════════════════════ */

/* Imposteur / Chaîne — éléments partagés */
.imp-round-badge { background:var(--bg3);border:2px solid var(--border-md);border-radius:999px;padding:0.38rem 1.3rem;font-size:0.82rem;font-weight:800;color:var(--text-muted);text-align:center; }
.imp-question-card { background:var(--card);border:1px solid var(--border-md);border-radius:var(--r-lg);padding:1.6rem 2rem;width:100%;box-shadow:var(--shadow);animation:questionSlide 0.4s cubic-bezier(0.34,1.56,0.64,1); }
.imp-question { font-size:clamp(1rem,2.5vw,1.2rem);font-weight:800;line-height:1.65;text-align:center; }
.imp-input-row { display:flex;gap:0.6rem;width:100%; }
.imp-text-input { flex:1;background:var(--bg3);border:2px solid var(--border-md);border-radius:var(--r-sm);color:var(--text);font-family:var(--font);font-size:0.97rem;font-weight:600;padding:0.75rem 1rem;outline:none;transition:border-color 0.2s;-webkit-user-select:text;user-select:text; }
.imp-text-input:focus { border-color:var(--cyan);box-shadow:0 0 0 4px rgba(0,212,255,0.15); }
.imp-answered { color:var(--green);font-size:0.9rem;font-weight:800;text-align:center;padding:0.6rem;width:100%; }
.imp-answers-list { display:flex;flex-direction:column;gap:0.5rem;width:100%; }
.imp-answer-row { background:var(--bg3);border:1px solid var(--border);border-radius:var(--r-sm);padding:0.6rem 1rem;display:flex;gap:0.8rem;align-items:center; }
.imp-answer-pseudo { font-weight:800;color:var(--cyan);font-size:0.82rem;min-width:70px; }
.imp-answer-text { font-weight:600;color:var(--text);font-size:0.9rem; }
.imp-vote-section { width:100%;text-align:center; }
.imp-vote-label { font-size:0.82rem;font-weight:800;color:var(--text-muted);margin-bottom:0.6rem; }
.imp-vote-row { display:flex;flex-wrap:wrap;gap:0.5rem;justify-content:center; }
.imp-vote-btn { min-width:80px; }
.imp-result-card { background:var(--card);border:1px solid var(--border-md);border-radius:var(--r-lg);padding:1.4rem 1.8rem;width:100%;display:flex;flex-direction:column;gap:0.7rem;box-shadow:var(--shadow); }
.imp-result-verdict { font-size:1rem;font-weight:800;color:var(--text);text-align:center; }
.imp-question-reveal { font-size:0.85rem;color:var(--text-muted);font-weight:600;padding:0.3rem 0;border-top:1px solid var(--border); }

/* Histoire mode select */
.histoire-mode-select { width:100%;padding:1rem;background:var(--card);border:1px solid var(--border-md);border-radius:var(--r-lg); }
.histoire-mode-btns { display:flex;gap:0.8rem;flex-wrap:wrap;justify-content:center; }
.histoire-mode-btn { flex:1;min-width:140px;padding:1rem;text-align:center;line-height:1.5;font-size:0.88rem; }
.histoire-mode-btn small { display:block;font-size:0.73rem;font-weight:600;color:var(--text-muted);margin-top:0.3rem; }

/* Chaîne */
.chaine-fin-badge { background:rgba(249,194,52,0.1);border:1px dashed rgba(249,194,52,0.4);border-radius:var(--r-sm);padding:0.55rem 1rem;font-size:0.82rem;font-weight:700;color:var(--yellow);text-align:center;width:100%; }

/* Pixel War */
.pw-grid { display:grid;gap:1px;width:min(92vw,440px);aspect-ratio:1;margin:0 auto;touch-action:none;user-select:none; }
.pw-cell { border-radius:2px;background:var(--bg3);transition:background 0.05s;cursor:crosshair;min-height:0; }

/* Bataille Navale */
.bn-grids { display:flex;gap:1.2rem;flex-wrap:wrap;justify-content:center;width:100%; }
.bn-grid-wrap { display:flex;flex-direction:column;align-items:center;gap:0.35rem; }
.bn-grid-label { font-size:0.75rem;font-weight:800;color:var(--text-muted);text-transform:uppercase;letter-spacing:0.06em; }
.bn-grid { display:grid;touch-action:none;user-select:none; }
.bn-cell { border-radius:2px;background:var(--bg3);border:1px solid var(--border);display:flex;align-items:center;justify-content:center;font-size:11px;transition:background 0.1s; }
.bn-cell.ship { background:rgba(0,212,255,0.25);border-color:var(--cyan); }
.bn-cell.hit { background:#be123c !important;border-color:#9f1239;cursor:default; }
.bn-cell.miss { background:var(--bg2) !important;border-color:var(--border);cursor:default;opacity:0.6; }
.bn-cell.sunk { background:#7f1d1d !important;border-color:#5f1616; }
.bn-cell.preview { background:rgba(0,245,255,0.2);border-color:var(--cyan); }
.bn-ships-palette { display:flex;gap:0.4rem;flex-wrap:wrap;justify-content:center;margin:0.4rem 0; }
.bn-ship-btn { padding:0.28rem 0.65rem;font-size:0.74rem;font-weight:800;border-radius:999px;border:2px solid var(--border-md);background:var(--bg3);color:var(--text);cursor:pointer;transition:all 0.15s;font-family:var(--font); }
.bn-ship-btn:hover:not(:disabled) { border-color:var(--cyan);color:var(--cyan); }
.bn-ship-btn.active { border-color:var(--cyan);color:var(--cyan);background:rgba(0,245,255,0.1); }
.bn-ship-btn.placed { opacity:0.35;text-decoration:line-through;cursor:not-allowed; }
.bn-theme-picker { display:flex;gap:0.5rem;justify-content:center;margin:0.4rem 0; }
.bn-theme-btn { padding:0.35rem 0.9rem;border-radius:999px;border:2px solid var(--border-md);background:var(--bg3);cursor:pointer;font-size:0.82rem;font-weight:700;color:var(--text);transition:all 0.15s;font-family:var(--font); }
.bn-theme-btn:hover { border-color:var(--yellow); }
.bn-theme-btn.active { border-color:var(--yellow);background:rgba(249,194,52,0.15); }

/* ═══════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

.hidden { display: none !important; }

/* ═══════════════════════════════════════
   AUTH — Connexion / Inscription
═══════════════════════════════════════ */
.auth-tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background: var(--bg2);
  border-radius: var(--r-lg);
  padding: 0.25rem;
}
.auth-tab {
  flex: 1;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.auth-tab.active {
  background: var(--card);
  color: var(--cyan);
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}
.auth-tab:hover:not(.active) {
  color: var(--text);
}

/* ═══════════════════════════════════════
   LOBBY TABS (Jouer / Mon Profil)
═══════════════════════════════════════ */
.lobby-tab-bar {
  display: flex; gap: 0.4rem;
  background: var(--bg2);
  border-radius: var(--r-lg);
  padding: 0.3rem;
  margin-bottom: 1.2rem;
}
.lobby-tab {
  flex: 1; padding: 0.6rem 0.8rem;
  font-size: 0.88rem; font-weight: 800;
  border: none; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
  font-family: var(--font); display: flex;
  align-items: center; justify-content: center; gap: 0.4rem;
}
.lobby-tab.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.lobby-tab:hover:not(.active) { color: var(--text); }

/* ═══════════════════════════════════════
   PROFILE PAGE
═══════════════════════════════════════ */
.profile-avatar-section {
  display: flex; align-items: flex-start; gap: 1.2rem;
}
.profile-avatar-current {
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg3); border: 2px solid var(--border-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; overflow: hidden;
}
.profile-avatar-current img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}
.profile-avatar-label {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 0.55rem;
}
.avatar-grid {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  margin-bottom: 0.6rem;
}
.avatar-emoji {
  width: 34px; height: 34px;
  font-size: 1.3rem;
  background: var(--bg3); border: 2px solid var(--border-md);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.avatar-emoji:hover { border-color: var(--cyan); transform: scale(1.12); }
.avatar-emoji.selected {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.12);
  box-shadow: 0 0 0 2px rgba(0,212,255,0.3);
}
.avatar-upload-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.38rem 0.85rem;
  background: var(--bg3); border: 1.5px solid var(--border-md);
  border-radius: 10px; color: var(--text-muted);
  font-family: var(--font); font-size: 0.78rem; font-weight: 700;
  cursor: pointer; transition: all 0.18s;
}
.avatar-upload-btn:hover { border-color: var(--cyan); color: var(--cyan); }

.profile-divider {
  height: 1px; background: var(--border-md);
  margin: 1.3rem 0;
}

/* ═══════════════════════════════════════
   FRIENDS PANEL
═══════════════════════════════════════ */
#friends-panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: 260px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
#friends-panel.collapsed {
  transform: translateX(228px);
}
.fp-header {
  display: flex; align-items: center;
  padding: 1rem 1rem 0.8rem;
  border-bottom: 1px solid var(--border);
  gap: 0.5rem; flex-shrink: 0;
}
.fp-title {
  font-size: 0.9rem; font-weight: 900;
  color: var(--text); flex: 1;
  display: flex; align-items: center; gap: 0.5rem;
}
.fp-toggle {
  background: none; border: 1px solid var(--border-md);
  border-radius: 8px; color: var(--text-muted);
  width: 28px; height: 28px;
  font-size: 1.1rem; font-weight: 900;
  cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
}
.fp-toggle:hover { border-color: var(--cyan); color: var(--cyan); }

.fp-body {
  flex: 1; overflow-y: auto;
  padding: 0.8rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.fp-body::-webkit-scrollbar { width: 3px; }
.fp-body::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }

.fp-section-label {
  font-size: 0.65rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); margin: 0.5rem 0 0.3rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.fp-divider { height: 1px; background: var(--border); margin: 0.6rem 0; }
.fp-empty { font-size: 0.78rem; color: var(--text-dim); padding: 0.3rem 0.2rem; }
.fp-searching { font-size: 0.78rem; color: var(--text-muted); padding: 0.4rem 0.2rem; }

/* Badge */
.fp-badge {
  background: var(--red); color: #fff;
  font-size: 0.62rem; font-weight: 900;
  padding: 0.08rem 0.38rem; border-radius: 999px;
  min-width: 16px; text-align: center;
}
.fp-badge.flash { animation: flashBadge 0.5s ease; }
@keyframes flashBadge {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.4); background: var(--yellow); }
}

/* Ligne ami */
.fp-friend-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.5rem; border-radius: 10px;
  cursor: pointer; transition: background 0.15s;
}
.fp-friend-row:hover { background: rgba(255,255,255,0.05); }
.fp-friend-avatar { position: relative; flex-shrink: 0; }
.fp-presence-dot {
  width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid var(--bg2);
  position: absolute; bottom: -1px; right: -1px;
}
.fp-presence-dot.on  { background: var(--green); box-shadow: 0 0 5px var(--green); }
.fp-presence-dot.off { background: var(--text-dim); }
.fp-pseudo {
  font-size: 0.83rem; font-weight: 700;
  color: var(--text); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fp-friend-actions {
  display: flex; align-items: center; gap: 0.25rem;
  opacity: 0; transition: opacity 0.15s;
}
.fp-friend-row:hover .fp-friend-actions { opacity: 1; }

/* Avatar mini */
.fp-avatar { flex-shrink: 0; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.fp-avatar-emoji { font-size: 1.2rem; line-height: 1; }
.fp-avatar-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

/* Boutons inline */
.fp-btn-remove, .fp-btn-invite {
  background: none; border: none; cursor: pointer;
  font-size: 0.75rem; padding: 0.15rem 0.3rem;
  border-radius: 6px; color: var(--text-dim);
  transition: all 0.15s;
}
.fp-btn-remove:hover { color: var(--red); background: rgba(255,61,90,0.1); }
.fp-btn-invite:hover { color: var(--cyan); background: rgba(0,212,255,0.1); }
.fp-unread-badge {
  background: var(--red); color: #fff;
  font-size: 0.6rem; font-weight: 900;
  padding: 0.05rem 0.35rem; border-radius: 999px;
}

/* Demandes en attente */
.fp-pending-row {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.3rem;
}
.fp-btn-accept, .fp-btn-decline {
  width: 26px; height: 26px;
  border-radius: 8px; border: none;
  font-size: 0.8rem; font-weight: 900; cursor: pointer;
  transition: all 0.15s; flex-shrink: 0;
}
.fp-btn-accept  { background: rgba(0,229,153,0.15); color: var(--green); }
.fp-btn-decline { background: rgba(255,61,90,0.12);  color: var(--red); }
.fp-btn-accept:hover  { background: rgba(0,229,153,0.3); }
.fp-btn-decline:hover { background: rgba(255,61,90,0.25); }

/* Recherche ami */
.fp-add-row {
  display: flex; gap: 0.4rem; margin-bottom: 0.4rem;
}
.fp-add-row input {
  flex: 1; background: var(--bg3);
  border: 1px solid var(--border-md); border-radius: 10px;
  color: var(--text); font-family: var(--font);
  font-size: 0.8rem; padding: 0.45rem 0.7rem; outline: none;
}
.fp-add-row input:focus { border-color: var(--cyan); }
.fp-add-btn {
  width: 34px; height: 34px;
  background: var(--bg3); border: 1px solid var(--border-md);
  border-radius: 10px; cursor: pointer; font-size: 0.85rem;
  transition: all 0.15s; flex-shrink: 0;
}
.fp-add-btn:hover { border-color: var(--cyan); }
.fp-search-result {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.3rem; border-radius: 8px;
  transition: background 0.15s;
}
.fp-search-result:hover { background: rgba(255,255,255,0.04); }
.fp-search-pseudo { font-size: 0.82rem; font-weight: 700; flex: 1; }
.fp-btn-add {
  background: rgba(0,212,255,0.1); color: var(--cyan);
  border: 1px solid rgba(0,212,255,0.25); border-radius: 8px;
  font-size: 0.75rem; font-weight: 800; padding: 0.25rem 0.6rem;
  cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.fp-btn-add:hover { background: rgba(0,212,255,0.2); }

/* Ajuster lobby pour le panneau */
.lobby-container { padding-right: calc(1.5rem + 0px); }
@media (min-width: 1080px) {
  body { padding-right: 260px; }
}

/* ═══════════════════════════════════════
   CHAT WINDOWS (bulles privées)
═══════════════════════════════════════ */
.chat-window {
  position: fixed;
  bottom: 0; right: 280px;
  width: 260px;
  background: var(--bg2);
  border: 1px solid var(--border-hi);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.5);
  z-index: 300;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.cw-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 0.8rem;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.cw-avatar { flex-shrink: 0; }
.cw-pseudo { font-size: 0.84rem; font-weight: 800; flex: 1; }
.cw-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 0.85rem; padding: 0.1rem 0.3rem;
  border-radius: 6px; transition: all 0.15s;
  font-family: var(--font);
}
.cw-close:hover { color: var(--red); background: rgba(255,61,90,0.1); }
.cw-body {
  display: flex; flex-direction: column;
  height: 280px;
}
.cw-messages {
  flex: 1; overflow-y: auto;
  padding: 0.7rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.cw-messages::-webkit-scrollbar { width: 3px; }
.cw-messages::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 4px; }
.cw-msg {
  max-width: 80%;
  padding: 0.45rem 0.75rem;
  border-radius: 14px;
  font-size: 0.82rem; line-height: 1.45;
  word-break: break-word;
}
.cw-msg.mine {
  background: rgba(0,212,255,0.18);
  color: var(--text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.cw-msg.theirs {
  background: var(--bg4, var(--bg3));
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.cw-input-row {
  display: flex; gap: 0.4rem;
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--border);
}
.cw-input-row input {
  flex: 1; background: var(--bg3);
  border: 1px solid var(--border-md); border-radius: 10px;
  color: var(--text); font-family: var(--font);
  font-size: 0.82rem; padding: 0.4rem 0.7rem; outline: none;
}
.cw-input-row input:focus { border-color: var(--cyan); }
.cw-send-btn {
  width: 32px; height: 32px;
  background: var(--cyan); border: none; border-radius: 10px;
  color: #000; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: opacity 0.15s; flex-shrink: 0;
}
.cw-send-btn:hover { opacity: 0.85; }

/* Toast invitation */
.invite-toast {
  background: var(--card2);
  border: 1px solid var(--yellow);
  border-left: 4px solid var(--yellow);
  border-radius: var(--r-sm);
  padding: 0.85rem 1.1rem;
  font-size: 0.84rem; font-weight: 700;
  max-width: 280px;
}

/* Mobile : cacher le panneau, afficher une icône */
@media (max-width: 900px) {
  #friends-panel { transform: translateX(100%); }
  #friends-panel.mobile-open { transform: translateX(0); }
  body { padding-right: 0; }
  .chat-window { right: 0 !important; width: 100vw; border-radius: 14px 14px 0 0; }
}

/* Bouton flottant mobile pour ouvrir le panneau amis */
#friends-mobile-fab {
  display: none;
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  z-index: 201;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--cyan);
  color: #000;
  font-size: 1.4rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,212,255,0.4);
  align-items: center; justify-content: center;
  transition: transform 0.2s;
}
#friends-mobile-fab:active { transform: scale(0.92); }
@media (max-width: 900px) {
  #friends-mobile-fab { display: flex; }
}
