/* ===========================
   RESET & BASE
   =========================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

h2 {
  color: #dde0f0 !important;
}
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3250;
  --text: #e8eaf6;
  --text-muted: #eaeaea;
  --accent: #6c63ff;
  --accent2: #a78bfa;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;

  /* Thème Histoire */
  --histoire-color: #c0932b;
  --histoire-bg: #2d2206;
  --histoire-border: #7a5c10;

  /* Thème Science */
  --science-color: #38bdf8;
  --science-bg: #061928;
  --science-border: #0e5b8a;

  /* Thème Géo */
  --geographie-color: #4ade80;
  --geographie-bg: #062010;
  --geographie-border: #156839;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===========================
   SCREENS
   =========================== */
.screen {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.35s ease;
}
.screen.active { display: block; }

/* Game screen uses full-height app-shell layout */
#screen-game.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

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

/* ===========================
   HOME SCREEN
   =========================== */
.home-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 60px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

.logo {
  text-align: center;
}

.logo-icon {
  font-size: 56px;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 18px rgba(108,99,255,0.6));
}

.logo-title {
  font-family: 'Playfair Display', serif;
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6c63ff, #a78bfa, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.logo-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-top: 8px;
}

/* ── Quick join ──────────────────────────────────────────── */
.quick-join-section {
  width: 100%;
  text-align: center;
}

.quick-join-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.quick-join-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  flex-wrap: wrap;
}

.quick-join-input {
  padding: .6rem .9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  width: 12rem;
}

.quick-join-input::placeholder { color: var(--text-muted); }

/* ── Themes ──────────────────────────────────────────────── */
.theme-section {
  width: 100%;
  text-align: center;
}

.theme-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.theme-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 600px) {
  .theme-cards { grid-template-columns: 1fr; }
  .logo-title { font-size: 2.2rem; }
}

.theme-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition);
  position: relative;
  overflow: hidden;
}

.theme-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition);
}

.theme-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.theme-card[data-theme="histoire"]:hover,
.theme-card[data-theme="histoire"].selected {
  border-color: var(--histoire-color);
  background: var(--histoire-bg);
  box-shadow: 0 0 0 3px rgba(192,147,43,0.2), var(--shadow);
}

.theme-card[data-theme="science"]:hover,
.theme-card[data-theme="science"].selected {
  border-color: var(--science-color);
  background: var(--science-bg);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.2), var(--shadow);
}

.theme-card[data-theme="geographie"]:hover,
.theme-card[data-theme="geographie"].selected {
  border-color: var(--geographie-color);
  background: var(--geographie-bg);
  box-shadow: 0 0 0 3px rgba(74,222,128,0.2), var(--shadow);
}

.theme-card[data-theme="cinema"]:hover,
.theme-card[data-theme="cinema"].selected {
  border-color: #e879f9;
  background: #2a0630;
  box-shadow: 0 0 0 3px rgba(232,121,249,0.2), var(--shadow);
}

.theme-card[data-theme="austen"]:hover,
.theme-card[data-theme="austen"].selected {
  border-color: #fb923c;
  background: #2d1a06;
  box-shadow: 0 0 0 3px rgba(251,146,60,0.2), var(--shadow);
}

.theme-emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.theme-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.theme-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===========================
   SELECTED THEME INFO
   =========================== */
.selected-theme-info p {
  color: var(--text-muted);
  font-size: 1rem;
}

.selected-theme-info strong {
  color: var(--text);
}

.selected-theme-info {
  text-align: center;
  animation: fadeIn 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.selected-theme-info > p { margin-bottom: 0; }
.selected-theme-info .btn-play { margin-top: 24px; }

.hidden { display: none !important; }

/* ===========================
   BUTTONS
   =========================== */
.btn-play {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 4px 20px rgba(108,99,255,0.4);
  letter-spacing: 0.3px;
}

.btn-play:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(108,99,255,0.55);
}

.btn-play:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--accent);
}

/* ===========================
   GAME SCREEN
   =========================== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.btn-back {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.btn-back:hover { color: var(--text); border-color: var(--accent); }

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header-theme-icon { font-size: 1.3rem; }

.header-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: uppercase;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-theme-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.header-theme-icon, .header-theme-badge { display: none; }

.score-display {
  display: none;
}

/* ===========================
   GAME MAIN
   =========================== */
.game-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 860px;
  width: 100%;
  align-self: center;
}

/* ===========================
   GAME SCROLL ZONE
   =========================== */
.game-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===========================
   LAST GUESS BANNER
   =========================== */
.last-guess-banner {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  animation: slideDown 0.3s ease;
  border-left: 4px solid transparent;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.last-guess-banner.frozen {
  background: rgba(120,120,120,0.12);
  border-color: #888;
  color: #aaa;
}
.last-guess-banner.cold {
  background: rgba(239,68,68,0.12);
  border-color: var(--danger);
  color: #fca5a5;
}
.last-guess-banner.warm {
  background: rgba(245,158,11,0.12);
  border-color: var(--warn);
  color: #fcd34d;
}
.last-guess-banner.hot {
  background: rgba(34,197,94,0.12);
  border-color: var(--success);
  color: #86efac;
}

/* ===========================
   GAME THEME BANNER
   =========================== */
.game-theme-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 1.5px solid var(--accent);
  background: var(--surface2);
  border-radius: 14px;
  padding: 12px 24px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.game-theme-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent) 0%, transparent 60%);
  opacity: 0.10;
  pointer-events: none;
}
.gtb-label {
  font-family: 'Playfair', serif;
  font-size: 0.95rem;
  font-weight: 400;
  color: #dde0f0;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.gtb-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 2.5px;
}

/* ===========================
   ARTICLE CARD
   =========================== */
.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  overflow: visible;
}

@media (max-width: 600px) {
  .article-card { padding: 18px 16px; }
  .game-scroll { padding: 10px 12px; gap: 12px; }
  .guess-section { padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* ── Mot à trouver (en haut de l'article) ── */
.target-word-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.target-word-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.target-word-display {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
}

.target-word-display.found {
  font-size: 1.5rem;
  font-weight: 800;
  color: #4ade80;
  font-family: 'Playfair Display', serif;
  letter-spacing: 2px;
}

.target-letter {
  display: inline-block;
  width: 18px;
  height: 28px;
  background: var(--surface2);
  border-bottom: 2px solid var(--accent);
  border-radius: 2px 2px 0 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: transparent;
  line-height: 28px;
}

.target-sep {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 1px;
}

.target-part-found {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fb923c;
  letter-spacing: 1px;
  font-family: 'Playfair Display', serif;
  border-bottom: 2px solid #fb923c;
  padding: 0 2px;
}

.article-text {
  font-size: 1.02rem;
  line-height: 1.9;
  color: var(--text);
  word-spacing: 2px;
}

/* Mots masqués */
.word-hidden {
  display: inline-block;
  background: var(--surface2);
  border-radius: 4px;
  color: transparent;
  user-select: none;
  vertical-align: middle;
  height: 1em;
  min-width: 2ch;
  margin: 0 1px;
  position: relative;
  transition: background var(--transition);
  cursor: pointer;
}

/* Placeholder mot cible – visuellement distinct */
.word-target-placeholder {
  display: inline-block;
  background: rgba(255, 193, 7, 0.12);
  border: 1.5px dashed rgba(255, 193, 7, 0.5);
  border-radius: 4px;
  color: transparent;
  user-select: none;
  vertical-align: middle;
  height: 1em;
  min-width: 2ch;
  margin: 0 1px;
  position: relative;
  cursor: pointer;
}

.word-hidden:hover {
  background: var(--border);
}

/* Badge nombre de lettres au clic */
.word-hidden.word-hidden-revealed {
  background: rgba(108,99,255,0.25);
  border: 1px solid rgba(108,99,255,0.5);
}

.word-hidden.word-hidden-revealed::after {
  content: attr(data-count-label);
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* Mots révélés */
.word-revealed {
  display: inline;
  border-radius: 4px;
  padding: 0 2px;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.word-revealed.exact {
  color: #ffffff;
  font-weight: 800;
  animation: pulse 0.5s ease;
}

@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ===========================
   GUESS SECTION
   =========================== */
.guess-section {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 20px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.guess-form {
  display: flex;
  gap: 10px;
}

.guess-form input {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.guess-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}

.guess-form input::placeholder { color: var(--text-muted); }

.btn-guess {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn-guess:hover { background: #7c74ff; }
.btn-guess:active { transform: scale(0.97); }

.hint-text {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 10px;
}

/* ===========================
   ATTEMPTS SECTION
   =========================== */
.attempts-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.attempts-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 14px;
}

.attempts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.attempt-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.93rem;
  animation: fadeIn 0.2s ease;
}

.attempt-word {
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
}

.attempt-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attempt-score {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 90px;
  text-align: right;
}

.attempt-bar-wrap {
  width: 80px;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.attempt-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.attempt-bar.frozen { background: #888; }
.attempt-bar.cold { background: var(--danger); }
.attempt-bar.warm { background: var(--warn); }
.attempt-bar.hot  { background: var(--success); }
.attempt-bar.exact{ background: var(--accent2); }

.attempt-number {
  min-width: 22px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
}

.attempt-player-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ===========================
   MODAL
   =========================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modalPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { transform: scale(0.85) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
  animation: bounce 0.6s ease 0.2s both;
}

@keyframes bounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.modal-message {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 20px;
}

.modal-message strong { color: var(--text); }

.modal-word-reveal {
  background: var(--surface2);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 28px;
  color: var(--accent2);
}

.modal-wiki-link {
  margin-bottom: 20px;
  text-align: center;
}

.modal-wiki-link a {
  color: #0073e6;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
  display: inline-block;
}

.modal-wiki-link a:hover {
  color: #0056b3;
  text-decoration: underline;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===========================
   SCROLLBAR
   =========================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===========================
   THEME COLORS ON GAME
   =========================== */
body[data-theme="histoire"] {
  --accent: var(--histoire-color);
  --accent2: #e5b96a;
}
body[data-theme="science"] {
  --accent: var(--science-color);
  --accent2: #7dd3fc;
}
body[data-theme="geographie"] {
  --accent: var(--geographie-color);
  --accent2: #86efac;
}
body[data-theme="cinema"] {
  --accent: #e879f9;
  --accent2: #f0abfc;
}
body[data-theme="austen"] {
  --accent: #fb923c;
  --accent2: #fdba74;
}

/* ===========================
   MODE SELECTION (accueil)
   =========================== */
.mode-section {
  margin-top: 28px;
  text-align: center;
}

.mode-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 16px;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  max-width: 440px;
  margin: 0 auto;
}

@media (max-width: 600px) {
  .mode-cards { grid-template-columns: 1fr; }
}

.mode-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.mode-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15), var(--shadow);
}

.mode-card.selected {
  border-color: var(--accent);
  background: rgba(108,99,255,0.08);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}

.mode-emoji { font-size: 2rem; }

.mode-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.mode-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

/* ════════════════════════════════════════════════
   SECTION MULTIJOUEUR (accueil)
   ════════════════════════════════════════════════ */
.online-section {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.online-name-row {
  display: flex;
  align-items: center;
  gap: .8rem;
}

.online-name-row label {
  font-size: .85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.online-name-row input {
  flex: 1;
  padding: .55rem .9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
}

.online-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  flex-wrap: wrap;
}

.btn-online-create {
  padding: .65rem 1.3rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-online-create:hover { opacity: .85; }

.input-code {
  width: 5rem;
  padding: .6rem .7rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-align: center;
  text-transform: uppercase;
}

.btn-online-join {
  padding: .7rem 1.4rem;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border: none;
  border-radius: 8px;
  color: white;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: all .2s ease;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
  letter-spacing: .5px;
}
.btn-online-join:hover {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 6px 16px rgba(34, 197, 94, 0.4);
  transform: translateY(-2px);
}
.btn-online-join:active {
  transform: translateY(0);
}

.online-error {
  color: #f87171;
  font-size: .85rem;
  margin-top: .2rem;
}
.online-error.info {
  color: #86efac;
  font-size: .95rem;
  font-weight: 600;
  margin-top: .8rem;
}

/* ════════════════════════════════════════════════
   ÉCRAN D'ATTENTE BLITZ
   ════════════════════════════════════════════════ */
#screen-blitz-waiting.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.waiting-container {
  width: 100%;
  max-width: 480px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.waiting-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.waiting-header h2 {
  font-size: 1.5rem;
  color: var(--text);
}

.waiting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.waiting-label {
  color: var(--text-muted);
  font-size: .95rem;
}

.waiting-code-box {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.waiting-code-text {
  font-family: 'Courier New', monospace;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: .3em;
  color: var(--accent);
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: .3rem 1rem;
}

.btn-copy {
  padding: .55rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-copy:hover { background: var(--surface); }

.waiting-status {
  color: var(--text-muted);
  font-size: .9rem;
}

/* Spinner */
.waiting-spinner {
  margin-top: .5rem;
}
.spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════
   MODE BLITZ
   ════════════════════════════════════════════════ */

/* --- Salle d'attente blitz --- */
.blitz-waiting-players {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.blitz-waiting-player {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-weight: 600;
}
.blitz-waiting-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* --- Barre joueurs blitz (screen-game) --- */
.blitz-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.blitz-player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 2px solid var(--border);
  min-width: 80px;
  font-size: .82rem;
  transition: border-color .3s, background .3s;
}
.blitz-player-card.blitz-me {
  border-color: var(--accent);
  background: rgba(99,102,241,.08);
}
.blitz-player-card.blitz-winner {
  border-color: #f59e0b;
  background: rgba(245,158,11,.12);
  animation: blitz-winner-pulse 1s ease-in-out 3;
}
.blitz-player-name {
  font-weight: 700;
  font-size: .85rem;
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.blitz-player-tries {
  font-size: .75rem;
  opacity: .65;
}

/* --- Barre de progression révélation --- */
.blitz-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  opacity: .75;
  flex-shrink: 0;
}
.blitz-progress-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.blitz-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, #6366f1, #22c55e);
  transition: width .5s ease;
}

/* --- Mot nouvellement révélé (animation) --- */
@keyframes blitz-appear {
  from { opacity: 0; transform: translateY(-4px) scale(.9); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.word-new {
  animation: blitz-appear .35s ease-out;
  color: #ffffff;
}

/* --- Animation victoire blitz --- */
@keyframes blitz-winner-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.06); }
}

/* --- Badge joueur dans tentatives blitz --- */
.attempt-player-badge.blitz-badge {
  background: rgba(99,102,241,.18);
  color: var(--accent);
}

/* --- Récap blitz dans modal --- */
.blitz-recap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
  text-align: left;
}

.blitz-recap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.blitz-recap-row.winner {
  color: var(--success);
}

.blitz-recap-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.blitz-recap-score {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.blitz-recap-row.winner .blitz-recap-score {
  color: var(--success);
}

/* ═══════════════════════════════════════════════════════════
   SOLO BLITZ
   ═══════════════════════════════════════════════════════════ */
.solo-blitz-bar {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 auto .6rem;
  max-width: 680px;
  flex-shrink: 0;
}
.solo-blitz-progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  overflow: hidden;
}
.solo-blitz-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 4px;
  transition: width .4s ease;
}
.solo-blitz-progress-fill.danger {
  background: linear-gradient(90deg, #ef4444, #f97316);
}
.solo-blitz-reveal-text {
  font-size: .78rem;
  opacity: .7;
  white-space: nowrap;
}
.solo-blitz-bar.hidden { display: none; }

/* ===========================
   CHALLENGE DU JOUR
   =========================== */

/* ── Bannière accueil ──────────────────────────────────────── */
@keyframes challenge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,58,237,0), 0 4px 20px rgba(124,58,237,.25); }
  50%       { box-shadow: 0 0 0 4px rgba(124,58,237,.3), 0 4px 20px rgba(124,58,237,.4); }
}
.challenge-home-banner {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.3rem 1.6rem;
  background: linear-gradient(135deg, #2e1060 0%, #4c1d95 60%, #5b21b6 100%);
  border: 1.5px solid #8b5cf6;
  border-left: 4px solid #a78bfa;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  animation: challenge-pulse 2.8s ease-in-out infinite;
}
.challenge-home-banner:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(124,58,237,.5) !important;
  animation: none;
}
.challenge-home-icon { font-size: 2.2rem; flex-shrink: 0; }
.challenge-home-text { display: flex; flex-direction: column; flex: 1; }
.challenge-home-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.challenge-home-title {
  font-weight: 800;
  font-size: 1.1rem;
  background: linear-gradient(90deg, #c4b5fd, #f0abfc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.challenge-home-badge {
  font-size: 0.92rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid;
  flex-shrink: 0;
  align-self: center;
  text-align: center;
  margin-right: 0.6rem;
}
.challenge-home-badge[data-theme="histoire"]   { color: var(--histoire-color); border-color: var(--histoire-color); background: rgba(192,147,43,.12); }
.challenge-home-badge[data-theme="science"]    { color: var(--science-color); border-color: var(--science-color); background: rgba(56,189,248,.12); }
.challenge-home-badge[data-theme="geographie"] { color: var(--geographie-color); border-color: var(--geographie-color); background: rgba(74,222,128,.12); }
.challenge-home-badge[data-theme="cinema"]     { color: #e879f9; border-color: #e879f9; background: rgba(232,121,249,.12); }
.challenge-home-badge[data-theme="austen"]     { color: #fb923c; border-color: #fb923c; background: rgba(251,146,60,.12); }
.challenge-home-desc { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }

/* ── Bottom-sheet : mode de jeu ────────────────────────────── */
.theme-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.theme-modal-overlay.hidden { display: none !important; }

@keyframes popInModal {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.theme-modal-sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 28px 28px 32px;
  animation: popInModal .2s cubic-bezier(.32,1,.6,1);
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.theme-modal-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: 4px;
}
.theme-modal-icon-el  { font-size: 1.8rem; }
.theme-modal-label-el {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--text);
  flex: 1;
}
.theme-modal-close {
  background: none;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.theme-modal-close:hover { color: var(--text); border-color: var(--accent); }
.theme-modal-sheet .mode-section { margin-top: 16px; }
.theme-modal-sheet .btn-play { display: block; width: 100%; margin-top: 20px; }

/* ── Barre de progression challenge (dans screen-game) ─────── */
.challenge-bar {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .4rem 1rem;
  background: rgba(124,58,237,.12);
  border-bottom: 1px solid rgba(124,58,237,.2);
  flex-shrink: 0;
}
.challenge-bar.hidden { display: none; }
.challenge-bar-label {
  font-size: .82rem;
  font-weight: 700;
  color: #c4b5fd;
  white-space: nowrap;
}
.challenge-bar-steps { display: flex; gap: .35rem; }
.challenge-bar-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s;
}
.challenge-bar-dot.current {
  background: #7c3aed;
  box-shadow: 0 0 6px #7c3aed;
}
.challenge-bar-dot.done { background: #22c55e; }

/* ── Écran Intro ───────────────────────────────────────────── */
.challenge-intro-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
}
.challenge-intro-header { text-align: center; }
.challenge-intro-icon { font-size: 3rem; display: block; margin-bottom: .5rem; }
.challenge-intro-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  background: linear-gradient(135deg, #c4b5fd, #f0abfc);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.challenge-intro-theme {
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: .5rem;
  color: var(--accent2);
}
.challenge-intro-rules {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: .6rem;
  line-height: 1.7;
}
.challenge-intro-rules strong { color: var(--text); }
.challenge-pseudo-section {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.challenge-pseudo-section label {
  font-weight: 600;
  font-size: .95rem;
}
.challenge-pseudo-section input {
  padding: .7rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.challenge-pseudo-section input::placeholder { color: var(--text-muted); }
.challenge-leaderboard-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.challenge-leaderboard-preview h3 { font-size: .95rem; margin-bottom: .7rem; color: var(--text-muted); }

/* ── Écran Résultat mot ────────────────────────────────────── */
.challenge-result-container {
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
}
.challenge-result-header { width: 100%; text-align: center; }
.challenge-result-num {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.challenge-result-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.challenge-result-status {
  font-size: 1.1rem;
  font-weight: 700;
}
.challenge-result-status.status-found { color: var(--success); }
.challenge-result-status.status-lost  { color: var(--danger); }
.challenge-result-word {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
}
.challenge-result-stars { font-size: 1.6rem; letter-spacing: .2rem; }
.challenge-result-pts { font-size: 1.3rem; font-weight: 800; color: var(--accent2); }
.challenge-scores-so-far {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* ── Score rows (partagé résultat + final) ─────────────────── */
.challenge-score-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  padding: .25rem 0;
}
.challenge-score-row.csr-latest { font-weight: 700; color: var(--accent2); }
.csr-num      { width: 3.5rem; color: var(--text-muted); font-size: .8rem; flex-shrink: 0; }
.csr-word     { flex: 1; font-family: 'Playfair Display', serif; }
.csr-stars    { font-size: .95rem; letter-spacing: .1rem; flex-shrink: 0; }
.csr-pts      { width: 4rem; text-align: right; font-weight: 700; color: var(--accent2); flex-shrink: 0; }

/* ── Écran Final ───────────────────────────────────────────── */
.challenge-final-container {
  max-width: 580px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
}
.challenge-final-header { text-align: center; }
.challenge-final-icon  { font-size: 3.5rem; display: block; margin-bottom: .5rem; }
.challenge-final-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.challenge-final-sub { color: var(--text-muted); font-size: .9rem; margin-top: .4rem; }
.challenge-final-score {
  font-size: 2.6rem;
  font-weight: 900;
  text-align: center;
}
.challenge-final-total-pts {
  background: linear-gradient(135deg, #fde68a, #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.challenge-final-max { color: var(--text-muted); font-size: 1.2rem; font-weight: 600; }
.challenge-final-breakdown {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.challenge-share-box {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.challenge-share-text {
  font-family: monospace;
  font-size: .85rem;
  white-space: pre;
  color: var(--text-muted);
  line-height: 1.6;
}
.challenge-leaderboard-full {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.challenge-leaderboard-full h3 {
  font-size: .95rem;
  margin-bottom: .8rem;
  color: var(--text-muted);
}

/* ── Leaderboard rows ──────────────────────────────────────── */
.lb-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
}
.lb-row:nth-child(odd) { background: rgba(255,255,255,.02); }
.lb-row-me { background: rgba(108,99,255,.12) !important; font-weight: 700; }
.lb-rank   { width: 2rem; flex-shrink: 0; text-align: center; }
.lb-pseudo { flex: 1; }
.lb-pts    { font-weight: 700; color: var(--accent2); }
.lb-empty  { color: var(--text-muted); font-size: .88rem; font-style: italic; }

/* ── Overlay entre manches (Blitz multi) ──────────────────── */
.blitz-round-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 40, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  animation: popInModal .25s ease;
}
.blitz-round-overlay.hidden { display: none; }

.blitz-round-card {
  background: var(--card-bg);
  border: 1px solid rgba(108,99,255,.3);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  min-width: 300px;
  max-width: 480px;
  width: 90%;
  text-align: center;
}

.bro-round {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: .5rem;
}
.bro-status {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .4rem;
}
.bro-word {
  font-size: 1.1rem;
  color: var(--accent2);
  margin-bottom: 1.2rem;
  font-style: italic;
}
.bro-scores-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.bro-score-row {
  display: flex;
  justify-content: space-between;
  padding: .3rem .6rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: rgba(255,255,255,.04);
}
.bro-score-row.bro-me {
  background: rgba(108,99,255,.15);
  font-weight: 700;
  color: var(--accent);
}

/* ── Badge IMDb ─────────────────────────────────────────────── */
.imdb-badge {
  display: inline-block;
  background: #f5c518;
  color: #000;
  font-weight: 700;
  font-size: .85rem;
  padding: .25rem .6rem;
  border-radius: var(--radius-sm);
  letter-spacing: .02em;
}
#challenge-result-imdb {
  margin-top: .5rem;
  text-align: center;
}
#bro-imdb {
  margin-bottom: .8rem;
  text-align: center;
}
