/* ═══════════════════════════════════════
   THÈME — variables partagées par tout le site (jeux inclus, room.css/
   daily.css les réutilisent). Clair par défaut ; le thème sombre (palette
   d'origine du site, inchangée) s'active via [data-theme="dark"] sur
   <html>, posé côté serveur depuis la préférence du compte (voir
   rooms.context_processors.active_theme et templates/base.html).
   Le switch se fait dans la page profil. ═══════════════════════════════ */
:root {
  --bg: #f6f6fb;
  --bg2: #ffffff;
  --bg3: #edeef5;
  --border: #e0e1eb;
  --accent: #7c6aff;
  --accent2: #ff6a9d;
  --accent-soft: #ece9ff;
  --text: #17171f;
  --text-dim: #6b6b7a;
  --success: #15803d;
  --error: #dc2626;
  --warning: #b45309;
  --radius: 12px;
  --mono: 'DM Mono', monospace;
  --sans: 'Syne', sans-serif;
}

[data-theme="dark"] {
  --bg: #0a0a0f;
  --bg2: #111118;
  --bg3: #1a1a24;
  --border: #2a2a3a;
  --accent: #7c6aff;
  --accent2: #ff6a9d;
  --accent-soft: #241f3d;
  --text: #e8e8f0;
  --text-dim: #888899;
  --success: #4ade80;
  --error: #f87171;
  --warning: #fbbf24;
}

/* Transition douce lors du switch (évite le flash brutal), sans gêner les
   animations propres à chaque composant (spécificité plus élevée ailleurs). */
body, .navbar, .alert, .modal-box, .day-pip-bar, .tile, .kb-key,
input, textarea, select, button {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Les spinners natifs des <input type="number"> ne sont stylés par aucun
   navigateur cohérent avec le thème (rendu en simple carré gris sur
   certains WebView) et cassent le centrage du texte (ex: saisie d'année
   dans "Devine la date"). On les masque partout et on garde le clavier
   numérique via inputmode="numeric" côté HTML. */
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; appearance: none; margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

/* NAV */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,15,0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links { display: flex; align-items: center; gap: 1rem; }

.nav-user {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn {
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}
.nav-btn:hover { background: #6b59ee; transform: translateY(-1px); }

/* Menu burger (pseudo + ≡) : bouton déclencheur + dropdown */
.nav-menu { position: relative; }

.nav-menu-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text);
  font-family: var(--sans);
  appearance: none;
  transition: all 0.2s;
}
.nav-menu-trigger:hover,
.nav-menu.open .nav-menu-trigger {
  border-color: var(--accent);
  /* Fond OPAQUE et adapté au thème — la navbar a elle-même un fond sombre
     fixe (rgba(10,10,15,0.9), non lié au thème) : un fond translucide ici
     laisserait ce sombre transparaître et rendrait le texte illisible en
     thème clair. --accent-soft règle ce problème dans les deux thèmes. */
  background: var(--accent-soft);
}

.nav-burger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 16px;
  flex-shrink: 0;
}
.nav-burger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-menu.open .nav-burger span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.nav-menu.open .nav-burger span:nth-child(2) { opacity: 0; }
.nav-menu.open .nav-burger span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.nav-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  min-width: 190px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 200;
}
.nav-menu.open .nav-menu-dropdown {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-menu-item:hover {
  background: rgba(124,106,255,0.12);
  color: var(--accent);
}
.nav-menu-item-icon { font-size: 1rem; }

/* iOS : empêche le zoom automatique sur focus des inputs (nécessite font-size ≥ 16px) */
@media (max-width: 768px) {
  input[type="text"],
  input[type="password"],
  input[type="email"],
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* Amélioration touch générale */
button, a, [onclick] {
  -webkit-tap-highlight-color: transparent;
}

/* MESSAGES */
.messages-container {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  backdrop-filter: blur(12px);
  animation: slideIn 0.3s ease;
  border: 1px solid;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  cursor: pointer;
}
.alert-success { background: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.3); color: var(--success); }
.alert-error { background: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.3); color: var(--error); }
.alert-info { background: rgba(124,106,255,0.1); border-color: rgba(124,106,255,0.3); color: var(--accent); }

.alert-text { flex: 1; }

/* Minuteur circulaire : le cercle "fg" se vide progressivement (via
   stroke-dashoffset, animé en JS) pour montrer visuellement que le
   message est temporaire et le temps qu'il reste avant disparition. */
.alert-timer { flex-shrink: 0; transform: rotate(-90deg); }
.alert-timer-bg { fill: none; stroke: currentColor; opacity: 0.25; stroke-width: 2; }
.alert-timer-fg {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  transition: stroke-dashoffset linear;
}

.alert.alert-dismissing {
  animation: slideOut 0.3s ease forwards;
  pointer-events: none;
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(20px); opacity: 0; }
}

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* AUTH PAGES */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at 30% 20%, rgba(124,106,255,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(255,106,157,0.06) 0%, transparent 60%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
}

.auth-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.auth-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.auth-logo {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
  display: block;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* FORMS */
.form-group { margin-bottom: 1.2rem; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.form-input, input[type="text"], input[type="password"], input[type="email"], textarea, select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  transition: all 0.2s;
  outline: none;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,106,255,0.15);
}

.form-errors { margin-top: 0.4rem; }
.form-errors li {
  font-size: 0.8rem;
  color: var(--error);
  list-style: none;
  font-family: var(--mono);
}

.form-hint {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  font-family: var(--mono);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6b59ee);
  color: white;
  width: 100%;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(124,106,255,0.3); }

/* Loader affiché sur un bouton de formulaire pendant l'attente de la réponse serveur */
.btn-loading {
  position: relative; color: transparent !important;
  pointer-events: none; opacity: 0.85; cursor: wait;
}
.btn-loading .btn-spinner {
  position: absolute; left: 50%; top: 50%; margin: -8px 0 0 -8px;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  border-radius: 50%; animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  background: rgba(248,113,113,0.1);
  color: var(--error);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

.auth-links { margin-top: 1.5rem; text-align: center; }
.auth-links a { color: var(--accent); text-decoration: none; font-size: 0.85rem; }
.auth-links a:hover { text-decoration: underline; }
.auth-links span { color: var(--text-dim); font-size: 0.85rem; }

.profile-actions {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
.profile-actions form { margin: 0; }
.profile-actions .btn { width: auto; }

/* ─── Switch de thème (page profil) ─── */
.theme-switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.9rem 1rem; margin-bottom: 1.5rem;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius);
}
.theme-switch-label { font-weight: 600; font-size: 0.9rem; }
.theme-switch-sub { font-size: 0.76rem; color: var(--text-dim); margin-top: 0.15rem; }

.theme-switch {
  position: relative; flex-shrink: 0;
  width: 56px; height: 30px; padding: 0 6px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
  cursor: pointer; transition: background 0.2s ease;
}
.theme-switch.is-dark { background: #24243a; }
.theme-switch-icon { font-size: 0.72rem; line-height: 1; z-index: 1; opacity: 0.8; }
.theme-switch-knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.theme-switch.is-dark .theme-switch-knob { transform: translateX(26px); }

.lang-flag-row { display: flex; gap: 0.4rem; flex-shrink: 0; }
.lang-flag-btn {
  width: 42px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border: 2px solid var(--border); border-radius: 8px;
  color: var(--text); cursor: pointer; overflow: hidden;
  opacity: 0.6; filter: saturate(0.7);
  transition: opacity 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}
.lang-flag-btn:hover { opacity: 0.9; filter: none; }
.lang-flag-btn.is-active { opacity: 1; filter: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lang-flag-img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

/* Choix de langue à l'inscription (RegisterForm.language, RadioSelect) —
   drapeaux en SVG (les emoji drapeaux s'affichent en lettres sous Windows). */
.lang-flag-choice-wrap { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.lang-flag-choice-wrap > div { display: contents; }
.lang-flag-choice-wrap label {
  display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem;
  padding: 0.45rem 0.7rem; border: 2px solid var(--border); border-radius: 8px;
  cursor: pointer; background: var(--bg2); color: var(--text);
}
.lang-flag-choice-wrap label::before {
  content: ''; width: 24px; height: 16px; border-radius: 2px; flex-shrink: 0;
  background-size: cover; background-position: center;
}
.lang-flag-choice-wrap label:has(input[value="fr"])::before { background-image: url('/static/img/flags/fr.svg'); }
.lang-flag-choice-wrap label:has(input[value="en"])::before { background-image: url('/static/img/flags/en.svg'); }
.lang-flag-choice-wrap label:has(input[value="es"])::before { background-image: url('/static/img/flags/es.svg'); }
.lang-flag-choice-wrap input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.lang-flag-choice-wrap label:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* HOME */
.home-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
}

.home-title { font-size: 2.2rem; font-weight: 800; }
.home-title span { color: var(--accent); }

.section-title {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}

.room-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  position: relative;
  overflow: hidden;
}
.room-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0;
  transition: opacity 0.2s;
}
.room-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.room-card:hover::before { opacity: 1; }

/* Carte "à jouer" — couleurs inversées */
.room-card--urgent {
  background: rgba(124,106,255,0.12);
  border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(124,106,255,0.15), 0 4px 20px rgba(124,106,255,0.1);
}
.room-card--urgent::before { opacity: 1; }
.room-card--urgent:hover { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(124,106,255,0.3), 0 8px 28px rgba(124,106,255,0.2); }

.room-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.room-card-name { font-size: 1.05rem; font-weight: 700; flex: 1; }

/* Badges statut */
.room-card-badge-play {
  flex-shrink: 0;
  padding: 0.15rem 0.55rem; border-radius: 20px;
  background: var(--accent); color: white;
  font-size: 0.7rem; font-weight: 700; font-family: var(--mono);
  white-space: nowrap;
}
.room-card-badge-done {
  flex-shrink: 0;
  padding: 0.15rem 0.55rem; border-radius: 20px;
  background: rgba(74,222,128,0.12); color: var(--success);
  border: 1px solid rgba(74,222,128,0.25);
  font-size: 0.7rem; font-family: var(--mono);
  white-space: nowrap;
}
.room-card-badge-break {
  flex-shrink: 0;
  padding: 0.15rem 0.55rem; border-radius: 20px;
  background: var(--bg3); color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 0.7rem; font-family: var(--mono);
  white-space: nowrap;
}

.room-card-desc { font-size: 0.82rem; color: var(--text-dim); line-height: 1.5; }

/* Bloc saison */
.room-card-season {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.45rem 0.65rem;
  background: rgba(124,106,255,0.06);
  border: 1px solid rgba(124,106,255,0.15);
  border-radius: 8px;
}
.room-card-season-label {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600;
  color: var(--accent);
}
.room-card-season-end {
  font-family: var(--mono); font-size: 0.68rem; color: var(--text-dim);
}
.room-card-rank {
  margin-left: auto;
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  color: var(--text);
}

.room-card-meta { font-family: var(--mono); font-size: 0.72rem; color: var(--text-dim); margin-top: auto; }

.badge-owner {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: rgba(124,106,255,0.15);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.7rem;
  font-family: var(--mono);
  margin-left: 0.5rem;
}

.empty-state {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ROOM PAGE */
.room-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 61px);
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  gap: 1rem;
}

.room-info { display: flex; flex-direction: column; gap: 0.2rem; }
.room-name { font-size: 1.2rem; font-weight: 700; }
.room-desc { font-size: 0.82rem; color: var(--text-dim); }

.room-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

.invite-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  max-width: 220px;
}
.invite-box:hover { border-color: var(--accent); color: var(--accent); }
.invite-url { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  animation: msgIn 0.2s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.own { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.msg-body { max-width: 65%; display: flex; flex-direction: column; gap: 0.2rem; }
.msg.own .msg-body { align-items: flex-end; }

.msg-meta { font-family: var(--mono); font-size: 0.7rem; color: var(--text-dim); }

.msg-text {
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  border-top-left-radius: 4px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.msg.own .msg-text {
  background: rgba(124,106,255,0.15);
  border-color: rgba(124,106,255,0.25);
  border-radius: 12px;
  border-top-right-radius: 4px;
}

.system-msg {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 0.4rem;
  animation: msgIn 0.2s ease;
}

.chat-input-area {
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

#chat-input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0.75rem 1.25rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s;
  resize: none;
  height: 46px;
  line-height: 1.5;
}
#chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,106,255,0.12); }

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  color: white;
}
.send-btn:hover { background: #6b59ee; transform: scale(1.05); }
.send-btn svg { width: 18px; height: 18px; }

.conn-status {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  margin-right: 6px;
  transition: background 0.3s;
}
.conn-status.connected { background: var(--success); box-shadow: 0 0 6px var(--success); }
.conn-status.disconnected { background: var(--error); }

/* JOIN PROMPT */
.join-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at center, rgba(124,106,255,0.06) 0%, transparent 70%);
}

.join-card {
  text-align: center;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem 2.5rem;
}

.join-icon { font-size: 3rem; margin-bottom: 1rem; }
.join-card h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.5rem; }
.join-card p { color: var(--text-dim); margin-bottom: 2rem; font-size: 0.9rem; }
.join-btns { display: flex; gap: 1rem; justify-content: center; }

/* 404 */
.notfound-page {
  min-height: calc(100vh - 61px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: radial-gradient(ellipse at center, rgba(124,106,255,0.08) 0%, transparent 70%);
  text-align: center;
}

.notfound-card { max-width: 480px; }

.notfound-glitch {
  position: relative;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(5rem, 20vw, 9rem);
  line-height: 1;
  letter-spacing: 4px;
  color: var(--text);
  margin-bottom: 0.5rem;
  user-select: none;
}
.notfound-glitch::before,
.notfound-glitch::after {
  content: '404';
  position: absolute;
  inset: 0;
  background: var(--bg);
  clip-path: inset(0 0 0 0);
}
.notfound-glitch::before {
  color: var(--accent2);
  animation: nf-glitch-1 3.2s infinite linear alternate-reverse;
}
.notfound-glitch::after {
  color: var(--accent);
  animation: nf-glitch-2 2.4s infinite linear alternate-reverse;
}
@keyframes nf-glitch-1 {
  0%   { clip-path: inset(10% 0 78% 0); transform: translate(-2px,0); }
  20%  { clip-path: inset(60% 0 12% 0); transform: translate(2px,0); }
  40%  { clip-path: inset(30% 0 45% 0); transform: translate(-3px,0); }
  60%  { clip-path: inset(75% 0 5% 0);  transform: translate(3px,0); }
  80%  { clip-path: inset(5% 0 85% 0);  transform: translate(-1px,0); }
  100% { clip-path: inset(45% 0 35% 0); transform: translate(1px,0); }
}
@keyframes nf-glitch-2 {
  0%   { clip-path: inset(70% 0 15% 0); transform: translate(2px,0); }
  25%  { clip-path: inset(15% 0 70% 0); transform: translate(-2px,0); }
  50%  { clip-path: inset(40% 0 40% 0); transform: translate(3px,0); }
  75%  { clip-path: inset(5% 0 88% 0);  transform: translate(-3px,0); }
  100% { clip-path: inset(58% 0 20% 0); transform: translate(1px,0); }
}

.notfound-emoji { font-size: 2.4rem; margin-bottom: 0.75rem; }
.notfound-card h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 0.5rem; }
.notfound-card p { color: var(--text-dim); margin-bottom: 2rem; font-size: 0.95rem; }
.notfound-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

@media (max-width: 480px) {
  .notfound-btns { flex-direction: column; align-items: stretch; }
  .notfound-btns .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .notfound-glitch::before, .notfound-glitch::after { animation: none; }
}

/* ─── PAGE MAINTENANCE (même gabarit que le 404, texte différent) ─── */
.maintenance-glitch {
  position: relative;
  font-family: var(--sans);
  font-weight: 800;
  /* "MAINTENANCE" (11 caractères) est bien plus large que "404" — un
     clamp() calqué sur .notfound-glitch la faisait déborder de la carte
     (480px) sur desktop, ce qui décalait le mot hors centre ET laissait
     la partie qui dépassait sans effet glitch (les pseudo-éléments,
     positionnés en inset:0 par rapport à la boîte réelle, s'arrêtent
     pile où elle s'arrête). Valeurs nettement réduites en conséquence.
  */
  font-size: clamp(1.3rem, 5.5vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: 0.5px;
  color: var(--text);
  margin-bottom: 0.5rem;
  user-select: none;
  text-align: center;
  width: 100%;
  overflow-wrap: break-word;
  word-break: break-word;
}
.maintenance-glitch::before,
.maintenance-glitch::after {
  content: 'MAINTENANCE';
  position: absolute;
  inset: 0;
  background: var(--bg);
  clip-path: inset(0 0 0 0);
}
.maintenance-glitch::before {
  color: var(--accent2);
  animation: nf-glitch-1 3.2s infinite linear alternate-reverse;
}
.maintenance-glitch::after {
  color: var(--accent);
  animation: nf-glitch-2 2.4s infinite linear alternate-reverse;
}
@media (prefers-reduced-motion: reduce) {
  .maintenance-glitch::before, .maintenance-glitch::after { animation: none; }
}


/* CREATE ROOM */
.create-page {
  min-height: calc(100vh - 61px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 2rem;
}

.create-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
}

.page-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.5rem; }
.page-subtitle { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 2rem; }

/* MEMBERS */
.members-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.members-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-right: 0.5rem;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-dim);
}

.member-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--success); }

/* MISC */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
textarea { resize: vertical; }

.helptext {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--mono);
  margin-top: 0.3rem;
}

ul.helptext { list-style: none; }
ul.helptext li::before { content: "→ "; color: var(--accent); }

/* ═══════════════════════════════════════
   RESPONSIVE — TABLETTE (≤ 768px)
═══════════════════════════════════════ */
@media (max-width: 768px) {

  /* NAV */
  .navbar {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }
  .nav-logo { font-size: 1.1rem; }
  .nav-links { gap: 0.5rem; }
  /* Le username est maintenant l'unique porte d'accès au profil (mot de
     passe + déconnexion y ont été déplacés) — il doit donc rester visible
     et cliquable à toutes les tailles d'écran, plus question de le cacher. */
  .nav-menu-trigger { padding: 0.3rem 0.55rem; }
  .nav-user { font-size: 0.75rem; max-width: 100px; }
  .nav-btn { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

  /* ALERTS */
  .messages-container {
    top: 4rem;
    right: 0.75rem;
    left: 0.75rem;
  }
  .alert { font-size: 0.82rem; padding: 0.6rem 1rem; }

  /* AUTH */
  .auth-card {
    padding: 1.75rem 1.25rem;
    border-radius: 16px;
  }
  .auth-title { font-size: 1.6rem; }

  /* HOME */
  .home-page { padding: 1.5rem 1rem; }
  .home-header { margin-bottom: 1.5rem; }
  .home-title { font-size: 1.6rem; }
  .rooms-grid { grid-template-columns: 1fr; }

  /* CREATE / JOIN */
  .create-page { padding: 1.5rem 1rem; }
  .create-card { padding: 1.5rem 1.25rem; border-radius: 16px; }
  .page-title { font-size: 1.4rem; }
  .join-card { padding: 2rem 1.5rem; }
  .join-btns { flex-direction: column; align-items: stretch; }
  .join-btns .btn { width: 100%; }

  /* ROOM PAGE */
  .room-page { height: calc(100dvh - 56px); } /* dvh pour mobile browsers */
  .room-header {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
  }
  .room-name { font-size: 0.95rem; }
  .room-desc { display: none; } /* trop court sur mobile */
  .room-actions { gap: 0.35rem; }
  .invite-box { max-width: 120px; }
  .invite-url { display: none; } /* icône suffit sur mobile */

  /* MEMBERS BAR */
  .members-bar { padding: 0.4rem 0.75rem; }

  /* SCOREBOARD — scrollable horizontalement */
  .scoreboard-area { padding: 1rem 0.75rem; }
  .scoreboard-title { font-size: 1.1rem; }
  #sb-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sb-table th, .sb-table td { padding: 0.6rem 0.6rem; font-size: 0.78rem; white-space: nowrap; }
}

/* ═══════════════════════════════════════
   RESPONSIVE — SMARTPHONE (≤ 480px)
═══════════════════════════════════════ */
@media (max-width: 480px) {

  /* NAV : username + "+ Salle" suffisent, le reste vit dans le menu burger */
  .nav-user { max-width: 70px; }

  /* AUTH */
  .auth-page { padding: 1rem; align-items: flex-start; padding-top: 3rem; }
  .auth-card { padding: 1.5rem 1rem; }

  /* HOME */
  .home-page { padding: 1rem 0.75rem; }
  .home-title { font-size: 1.4rem; }
  .home-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .home-header .btn { width: 100%; justify-content: center; }

  /* ROOM HEADER — ultra compact */
  .room-header { padding: 0.5rem 0.6rem; }
  .room-name { font-size: 0.85rem; }
  .btn-sm { padding: 0.3rem 0.6rem; font-size: 0.72rem; }
  .invite-box { padding: 0.3rem 0.5rem; }
}

/* ── Bouton Buy me a coffee ── */
.bmc-footer {
  position: fixed; bottom: 1rem; left: 0; right: 0; z-index: 10;
  display: flex !important; justify-content: center !important; align-items: center;
  gap: 0.9rem;
  pointer-events: none; text-align: center;
}
.bmc-btn {
  display: inline-flex !important; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.25rem; border-radius: 20px; font-size: 0.82rem;
  font-weight: 700; text-decoration: none; cursor: pointer;
  border: none; outline: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,106,255,0.4);
  pointer-events: all;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.bmc-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(124,106,255,0.55);
}
.bmc-btn:active { transform: translateY(0); opacity: 0.9; }

/* Marge globale en bas de page pour ne pas être masqué par le bouton BMC */
body { padding-bottom: 3.5rem; }

/* ── Sur mobile : masquer footer flottant partout sauf la home ── */
@media (max-width: 768px) {
  .bmc-footer { display: none !important; }
  body { padding-bottom: 0; }
  body.page-home .bmc-footer { display: flex !important; }
  body.page-home { padding-bottom: 3.5rem; }
}
/* ═══ FEEDBACK BUTTON ═══ */
.feedback-trigger-btn {
  background: var(--bg3) !important;
  border: 1.5px solid var(--border) !important;
  color: var(--text-dim) !important;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3) !important;
}
.feedback-trigger-btn:hover {
  border-color: var(--accent) !important;
  color: var(--text) !important;
  box-shadow: 0 4px 16px rgba(124,106,255,0.25) !important;
}

/* ═══ FEEDBACK MODAL ═══ */
.fb-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
  padding: 1rem;
}
.fb-overlay.fb-open { opacity: 1; pointer-events: all; }

.fb-modal {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  width: 100%; max-width: 520px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  position: relative;
  transform: translateY(16px);
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
}
.fb-overlay.fb-open .fb-modal { transform: translateY(0); }

.fb-close {
  position: absolute; top: 1rem; right: 1rem;
  background: none; border: none; color: var(--text-dim);
  font-size: 1rem; cursor: pointer; padding: 0.25rem 0.5rem;
  border-radius: 6px; transition: color 0.15s, background 0.15s;
}
.fb-close:hover { color: var(--text); background: var(--bg3); }

.fb-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.4rem 1.5rem 0;
}
.fb-icon { font-size: 1.8rem; line-height: 1; }
.fb-title { font-family: var(--sans); font-weight: 700; font-size: 1.2rem; color: var(--text); }
.fb-subtitle { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.1rem; }

.fb-body { padding: 1.2rem 1.5rem 0; display: flex; flex-direction: column; gap: 0.75rem; }

.fb-label {
  display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-dim); text-transform: uppercase; margin-bottom: 0.3rem;
}
.fb-req { color: var(--accent2); }

.fb-input {
  width: 100%; background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text); font-family: var(--sans);
  font-size: 0.9rem; padding: 0.6rem 0.85rem;
  transition: border-color 0.15s;
  outline: none;
}
.fb-input:focus { border-color: var(--accent); }
.fb-textarea { resize: vertical; min-height: 90px; }
.fb-select { appearance: none; cursor: pointer; }

.fb-row { display: flex; gap: 0.75rem; }
.fb-col { flex: 1; min-width: 0; }

.fb-error {
  color: var(--error); font-size: 0.82rem;
  min-height: 1rem;
}

.fb-footer {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1.2rem 1.5rem 1.4rem;
}
.fb-btn-cancel {
  background: none; border: 1.5px solid var(--border);
  color: var(--text-dim); border-radius: 8px;
  padding: 0.55rem 1.2rem; font-family: var(--sans);
  font-size: 0.88rem; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.fb-btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
.fb-btn-submit {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #fff; border-radius: 8px;
  padding: 0.55rem 1.5rem; font-family: var(--sans);
  font-weight: 700; font-size: 0.88rem; cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.fb-btn-submit:hover { opacity: 0.88; transform: translateY(-1px); }
.fb-btn-submit:disabled { opacity: 0.5; cursor: default; transform: none; }

@media (max-width: 500px) {
  .fb-row { flex-direction: column; }
  .fb-modal { border-radius: 14px; }
}

/* ── Season Config Block (partagé create_room + admin) ── */
.season-config-block { display: flex; flex-direction: column; gap: 1rem; }
.scb-section {
  background: var(--bg2, #1a1a2e); border: 1px solid var(--border, #333);
  border-radius: 14px; overflow: hidden; padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.scb-section-title {
  font-weight: 700; font-size: 0.92rem; margin-bottom: 0.25rem;
}
.scb-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.scb-label {
  font-family: var(--mono); font-size: 0.72rem; color: var(--text-muted, #888);
  letter-spacing: 0.05em; min-width: 160px; flex-shrink: 0;
}
.scb-select, .scb-number {
  background: var(--bg3, #111); border: 1px solid var(--border, #333);
  border-radius: 8px; padding: 0.45rem 0.75rem;
  color: var(--text); font-family: var(--sans); font-size: 0.88rem;
  outline: none; transition: border-color 0.2s; cursor: pointer;
}
.scb-select:focus, .scb-number:focus { border-color: var(--accent); }
.scb-number { width: 80px; text-align: center; }
.scb-unit { font-size: 0.82rem; color: var(--text-muted, #888); }
.scb-hint {
  font-family: var(--mono); font-size: 0.7rem; color: var(--text-muted, #888);
  line-height: 1.5; margin: 0;
}
.scb-preview {
  padding: 0.6rem 0.85rem;
  background: rgba(124,106,255,0.06); border: 1px solid rgba(124,106,255,0.15);
  border-radius: 8px; font-family: var(--mono); font-size: 0.75rem;
  color: var(--text-muted, #888); line-height: 1.6;
}
.scb-preview strong { color: var(--accent); }
.scb-skip-days { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.scb-skip-day {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem; border-radius: 20px; cursor: pointer;
  background: var(--bg3, #111); border: 1px solid var(--border, #333);
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted, #888);
  transition: all 0.18s; user-select: none; touch-action: manipulation;
}
.scb-skip-day input[type="checkbox"] { display: none; }
.scb-skip-day:hover { border-color: var(--error); color: var(--error); }
.scb-skip-day.checked {
  background: rgba(248,113,113,0.1); border-color: var(--error); color: var(--error);
}
.scb-force-btn {
  align-self: flex-start;
  padding: 0.5rem 1.4rem; background: var(--accent); border: none;
  border-radius: 20px; color: white; font-family: var(--sans);
  font-size: 0.85rem; font-weight: 700; cursor: pointer; transition: all 0.2s;
  touch-action: manipulation;
}
.scb-force-btn:hover { background: #6b59ee; transform: translateY(-1px); }
.scb-force-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.scb-force-standalone { margin-top: 0.25rem; }
.create-card--wide { max-width: 680px; }
.scb-hint--warning { color: var(--error, #f87171) !important; }

/* ═══════════════════════════════════════
   MOBILE — KEYBOARD FIX
   Empêche le layout de sauter quand le
   clavier virtuel s'ouvre sur iOS/Android
═══════════════════════════════════════ */
@media (max-width: 768px) {

  /* Quand un input est focus, on veut que
     la room-page ne soit plus height-fixée
     pour éviter le redimensionnement brutal */
  body.kb-open .room-page {
    height: auto;
    min-height: calc(100dvh - 56px);
    overflow-y: auto;
  }

  /* L'input autocomplete (mystery, citygrid, quiz…)
     reste visible au-dessus du clavier via scroll,
     sans être éjecté par le redimensionnement */
  body.kb-open .flag-input-row,
  body.kb-open .cg-input-row,
  body.kb-open .quiz-input-row,
  body.kb-open .countries-input-row,
  body.kb-open .dg-input-row {
    position: sticky;
    bottom: 0.5rem;
    z-index: 50;
    background: var(--bg2, #1a1a2e);
    border-radius: 12px;
    padding: 0.5rem;
  }

  /* Évite le zoom auto sur iOS (font-size < 16px déclenche le zoom) */
  input[type="text"],
  input[type="search"],
  input[type="number"],
  select {
    font-size: 16px !important;
  }
}