/* === Roseo - Global Styles === */
:root {
  --bg: #0a0a1a; --card: #131329; --accent: #8b5cf6; --accent2: #a78bfa;
  --text: #e2e8f0; --muted: #94a3b8; --border: #1e1e3a;
  --danger: #ef4444; --success: #22c55e; --gold: #f59e0b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'SF Pro Display', 'Inter', system-ui, sans-serif; overflow-x: hidden; }

/* Flash toasts (sans daisyUI / default.css) */
.roseo-flash {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  left: 12px;
  z-index: 90;
  max-width: 420px;
  margin-left: auto;
  padding: 14px 40px 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(19, 19, 41, 0.96);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  animation: cardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 480px) {
  .roseo-flash { left: auto; width: min(420px, calc(100vw - 24px)); }
}
.roseo-flash.is-info { border-color: rgba(167, 139, 250, 0.45); }
.roseo-flash.is-error {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(46, 5, 22, 0.95);
}
.roseo-flash-title { font-weight: 800; margin-bottom: 4px; }
.roseo-flash-msg { color: var(--text); font-size: 0.92rem; line-height: 1.4; }
.roseo-flash-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.roseo-flash-close:hover { color: #fff; }

/* === Site header / navbar === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 26, 0.92);
  backdrop-filter: blur(14px);
}
.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 18px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 18px;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent2);
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.nav-brand-mark {
  display: inline-flex;
  width: 18px;
  height: 28px;
  color: var(--accent2);
}
.nav-brand-mark svg { width: 100%; height: 100%; }
.nav-brand-text { line-height: 1; }
.nav-primary {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: #fff; background: rgba(167, 139, 250, 0.08); }
.nav-link.is-active {
  color: #fff;
  background: rgba(139, 92, 246, 0.18);
}
.nav-link-muted { font-weight: 500; }
.nav-link-secondary { opacity: 0.9; }
.nav-btn {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.25);
}
.nav-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}

/* Mobile menu */
.nav-menu { display: none; position: relative; margin-left: auto; }
.nav-menu-toggle {
  list-style: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(19, 19, 41, 0.9);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-menu-toggle::-webkit-details-marker { display: none; }
.nav-menu-bars,
.nav-menu-bars::before,
.nav-menu-bars::after {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  position: relative;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-menu-bars::before,
.nav-menu-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-menu-bars::before { top: -5px; }
.nav-menu-bars::after { top: 5px; }
.nav-menu[open] .nav-menu-bars { background: transparent; }
.nav-menu[open] .nav-menu-bars::before { top: 0; transform: rotate(45deg); }
.nav-menu[open] .nav-menu-bars::after { top: 0; transform: rotate(-45deg); }
.nav-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(280px, calc(100vw - 28px));
  background: #131329;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  z-index: 50;
}
.nav-menu-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 14px;
  border-radius: 12px;
}
.nav-menu-link:hover,
.nav-menu-link.is-active {
  background: rgba(139, 92, 246, 0.16);
  color: #fff;
}
.nav-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 8px;
}
.nav-menu-cta {
  margin-top: 4px;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
}

@media (max-width: 820px) {
  .nav-primary,
  .nav-actions { display: none; }
  .nav-menu { display: block; }
}

/* === Auth pages === */
.auth-container { min-height: 80dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px; max-width: 400px; width: 100%; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 24px; text-align: center; }
.auth-back { color: var(--muted); text-decoration: none; font-size: 0.85rem; display: block; margin-bottom: 16px; }
.auth-back:hover { color: var(--accent2); }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.auth-field input { width: 100%; padding: 12px 16px; font-size: 1rem; border: 2px solid var(--border); border-radius: 10px; background: #0d0d24; color: #fff; outline: none; }
.auth-field input:focus { border-color: var(--accent); }
.field-error { color: var(--danger); font-size: 0.78rem; margin-top: 4px; }
.auth-btn { width: 100%; padding: 14px; background: linear-gradient(135deg, var(--accent), #7c3aed); color: #fff; border: none; border-radius: 12px; font-size: 1.05rem; font-weight: 700; cursor: pointer; margin-top: 8px; min-height: 48px; }
.auth-btn:hover { opacity: 0.95; }
.auth-btn-soft {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
.auth-btn-soft:hover {
  border-color: var(--accent);
  color: var(--accent2);
  opacity: 1;
}
.auth-lead {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: -12px 0 20px;
  word-break: break-word;
}
.auth-info {
  color: var(--success);
  font-size: 0.85rem;
  margin: 8px 0 4px;
  text-align: center;
}
.auth-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}
.auth-card-wide { max-width: 440px; }
.auth-switch { text-align: center; margin-top: 20px; color: var(--muted); font-size: 0.85rem; }
.auth-switch a { color: var(--accent2); }

/* === Home page === */
.home-root {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #20134a 0%, #0a0a1a 65%);
  position: relative; padding: 20px;
}
#bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.home-card {
  position: relative; z-index: 1;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 32px; padding: 48px 40px 36px; max-width: 460px; width: 100%;
  backdrop-filter: blur(30px); box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 120px rgba(139,92,246,0.12);
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.home-card-wide { max-width: 560px; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.logo-section { text-align: center; margin-bottom: 28px; }
.reed-icon { width: 52px; height: 84px; margin: 0 auto 12px; color: var(--accent2); animation: sway 3s ease-in-out infinite; }
@keyframes sway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

.app-title {
  font-size: clamp(2.6rem, 8vw, 3.4rem); font-weight: 900;
  background: linear-gradient(135deg, #ffffff, #a78bfa);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.04em; line-height: 1;
}
.home-lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin-top: 12px;
  line-height: 1.4;
  max-width: 28ch;
  margin-left: auto;
  margin-right: auto;
}
.tagline {
  color: var(--accent2); font-style: italic;
  font-size: 1rem; margin-top: 12px;
  letter-spacing: 0.02em;
}
.author { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.actions-stack { display: flex; flex-direction: column; gap: 18px; }

/* Homepage dual paths */
.home-paths {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.home-path {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 6px;
  padding: 18px 16px;
  min-height: 168px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #0d0d24;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.home-path:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(139, 92, 246, 0.22);
}
.home-path:active:not(:disabled) { transform: scale(0.98); }
.home-path:disabled,
.home-path.is-disabled {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}
.home-path-friends {
  background: linear-gradient(160deg, rgba(139, 92, 246, 0.22), #0d0d24 55%);
  border-color: rgba(167, 139, 250, 0.35);
}
.home-path-solo {
  background: linear-gradient(160deg, rgba(34, 197, 94, 0.12), #0d0d24 55%);
}
.home-path-kicker {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent2);
}
.home-path-solo .home-path-kicker { color: #4ade80; }
.home-path-title {
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.home-path-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
  flex: 1;
}
.home-path-cta {
  margin-top: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
}
.home-path-solo .home-path-cta { color: #86efac; }

.home-join {
  padding-top: 4px;
  margin-bottom: 8px;
}
.home-join-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 10px;
}
.home-join .btn-join {
  padding: 0 18px;
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 108px;
  justify-content: center;
}
.home-more {
  text-align: center;
  margin-top: 8px;
}
.home-guest-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 4px 0 0;
  opacity: 0.85;
}

.btn-create {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; padding: 18px 24px; border: none; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white; font-size: 1.15rem; font-weight: 800; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 30px rgba(139,92,246,0.45);
  letter-spacing: 0.02em;
}
.btn-create:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 14px 40px rgba(139,92,246,0.6);
  background: linear-gradient(135deg, #9f67f8, #8b5cf6);
}
.btn-create:active { transform: translateY(-1px) scale(0.995); }

.divider {
  display: flex; align-items: center; gap: 14px;
  color: var(--muted); font-size: 0.85rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.join-form { width: 100%; }
.code-input-group {
  display: flex; gap: 0;
  border: 2px solid var(--border);
  border-radius: 18px; overflow: hidden;
  transition: all 0.3s;
  background: #0d0d24;
}
.code-input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139,92,246,0.15), 0 0 24px rgba(139,92,246,0.2);
}
.code-input-group input {
  flex: 1; padding: 18px 20px;
  font-size: 1.4rem; font-weight: 800;
  letter-spacing: 10px; text-align: center;
  background: transparent; border: none;
  color: #fff; outline: none;
  text-transform: uppercase;
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  min-width: 0;
}
.code-input-group input::placeholder {
  color: #4a4a7a;
  letter-spacing: 6px;
  font-size: 1.1rem;
  font-weight: 500;
}
.btn-join {
  padding: 0 26px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border: none; color: white; cursor: pointer;
  display: flex; align-items: center;
  transition: all 0.25s;
  font-weight: 700;
}
.btn-join:hover {
  background: linear-gradient(135deg, #9f67f8, #8b5cf6);
}
.btn-join:disabled {
  background: #1e1e3a;
  color: #4a4a70;
  cursor: not-allowed;
}

.error-msg { color: var(--danger); text-align: center; margin: 14px 0; font-size: 0.85rem; }
.my-quizzes-link { display: block; text-align: center; color: var(--muted); margin-top: 16px; font-size: 0.85rem; }
.my-quizzes-link:hover { color: var(--accent2); }

/* Create page */
.create-page {
  position: relative; z-index: 1;
  max-width: 600px; width: 100%;
  margin: 0 auto; padding: 28px 24px;
  animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.create-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 32px;
}
.create-header h1 {
  font-size: clamp(1.45rem, 4vw, 1.75rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.back-link {
  color: var(--muted); text-decoration: none;
  font-size: 0.88rem; transition: all 0.2s;
  padding: 6px 12px; border-radius: 10px;
}
.back-link:hover {
  color: var(--accent2);
  background: rgba(167, 139, 250, 0.08);
}

/* Setup sections */
.setup-section { margin-bottom: 28px; }
.setup-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
  font-weight: 700;
}

/* Mode cards */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.mode-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 20px 12px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: #0d0d24;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.mode-card:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(139,92,246,0.2);
  background: linear-gradient(135deg, #121228, #1a1040);
}
.mode-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, #1a1040, #2a1a50);
  color: #fff;
  box-shadow: 0 8px 30px rgba(139,92,246,0.4);
  transform: translateY(-2px);
}
.mode-card-icon { font-size: 1.9rem; line-height: 1; }
.mode-card-label { font-size: 0.9rem; font-weight: 800; }
.mode-card-sub { font-size: 0.7rem; opacity: 0.8; }

/* Question count selector */
.count-selector { display: flex; gap: 10px; }
.count-btn {
  flex: 1; padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: #0d0d24;
  color: var(--muted);
  font-size: 1.2rem; font-weight: 800;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.count-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: #121228;
  transform: translateY(-2px);
}
.count-btn.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, #1a1040, #2a1a50);
  color: #fff;
  box-shadow: 0 6px 20px rgba(139,92,246,0.3);
}

/* Random tile (surprise me) */
.random-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; width: 100%;
  padding: 24px; margin-bottom: 14px;
  border: 2px solid var(--accent);
  border-radius: 20px;
  background: linear-gradient(135deg, #1a1040, #2a1a50);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.random-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(139,92,246,0.4);
  border-color: var(--accent2);
}
.random-tile:active { transform: translateY(-1px) scale(0.99); }
.random-tile-icon { font-size: 2.4rem; }
.random-tile-label { font-size: 1.1rem; font-weight: 800; color: #fff; }
.random-tile-sub { font-size: 0.8rem; color: var(--accent2); }
.mixed-tile {
  border-color: rgba(74, 222, 128, 0.45);
  background: linear-gradient(135deg, #102418, #1a1040);
}
.mixed-tile .random-tile-sub { color: #86efac; }

/* Meta-category grid */
.meta-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.meta-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 22px 12px;
  border: 2px solid var(--border);
  border-radius: 18px;
  background: #0d0d24;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.meta-tile:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, #121228, #1a1040);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(139,92,246,0.2);
}
.meta-tile:active { transform: translateY(-1px) scale(0.99); }
.meta-icon { font-size: 2rem; line-height: 1; }
.meta-name { font-size: 0.88rem; font-weight: 800; }
.meta-count {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--border);
  padding: 3px 10px;
  border-radius: 10px;
  font-weight: 600;
}

/* Category grid (sub-categories inside a meta) */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.category-tile {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 18px 10px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #0d0d24;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
}
.category-tile:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, #121228, #1a1040);
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(139,92,246,0.2);
}
.category-tile:active { transform: translateY(-1px) scale(0.98); }
.cat-icon { font-size: 1.8rem; line-height: 1; }
.cat-name { font-size: 0.78rem; font-weight: 700; line-height: 1.2; }
.cat-count {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--border);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

/* Category header (inside meta) */
.category-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.cat-back { background: none; border: none; color: var(--muted); font-size: 0.85rem; cursor: pointer; transition: color 0.2s; }
.cat-back:hover { color: var(--accent2); }
.cat-title { font-size: 1.1rem; font-weight: 700; }

.no-quiz-msg { text-align: center; padding: 30px 20px; color: var(--muted); }

/* === Room page === */
.room-root {
  max-width: 680px; margin: 0 auto;
  padding: 24px; min-height: 100dvh;
}
.room-topbar {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 24px;
}
.room-code-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 12px 18px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
.room-code-box:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(139,92,246,0.2);
  transform: translateY(-1px);
}
.code-label {
  font-size: 0.68rem; color: var(--muted);
  letter-spacing: 2.5px; font-weight: 600;
}
.code-val {
  font-size: 1.4rem; font-weight: 900;
  letter-spacing: 6px; color: #fff;
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
}
.copy-icon { font-size: 0.9rem; }
.question-progress {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  padding: 8px 18px;
  border-radius: 24px;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(139,92,246,0.35);
}

/* Join screen */
.join-screen { display: flex; align-items: center; justify-content: center; min-height: 70dvh; padding: 20px; }
.join-card {
  text-align: center; background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  animation: cardIn 0.5s ease-out;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 80px rgba(139, 92, 246, 0.1);
}
.join-quiz-info { margin-bottom: 24px; padding: 14px 18px; background: linear-gradient(135deg, #1a1040, #0d0d24); border-radius: 14px; border: 1px solid var(--border); }
.join-quiz-title { display: block; font-size: 1rem; font-weight: 800; color: var(--accent2); }
.join-quiz-meta { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.join-subtitle { color: var(--muted); font-size: 0.95rem; margin: -8px 0 24px; line-height: 1.5; }
.selected-avatar-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 28px; }
.preview-emoji {
  font-size: 3rem;
  line-height: 1;
  padding: 12px;
  background: #0d0d24;
  border-radius: 20px;
  border: 2px solid var(--border);
  animation: gentleFloat 3s ease-in-out infinite;
}
@keyframes gentleFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
}
.preview-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.join-card h2 { margin-bottom: 10px; font-size: 1.6rem; font-weight: 800; }

/* Avatar picker */
.avatar-picker { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 28px; }
.avatar-option {
  width: 56px; height: 56px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: #0d0d24;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.2s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-option:hover { transform: translateY(-3px) scale(1.1); border-color: var(--av-color); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.2); }
.avatar-option.active {
  border-color: var(--av-color);
  background: var(--av-color);
  box-shadow: 0 0 20px var(--av-color), 0 4px 24px var(--av-color);
  transform: translateY(-2px) scale(1.15);
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.name-form input {
  width: 100%;
  padding: 16px 20px;
  font-size: 16px; /* évite le zoom iOS */
  border: 2px solid var(--border);
  border-radius: 16px;
  background: #0d0d24;
  color: #fff;
  outline: none;
  transition: all 0.3s;
  text-align: center;
}
.name-form input::placeholder {
  color: #4a4a7a;
  font-style: italic;
}
.name-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15), 0 0 20px rgba(139, 92, 246, 0.2);
}
.btn-join-submit {
  padding: 16px 28px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.25s ease-out;
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  letter-spacing: 0.02em;
}
.btn-join-submit:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(139, 92, 246, 0.6);
  background: linear-gradient(135deg, #9f67f8, #8b5cf6);
}
.btn-join-submit:active:not(:disabled) {
  transform: translateY(-1px);
}
.btn-join-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Lobby */
.lobby { text-align: center; padding-top: 24px; }
.lobby-quiz-banner {
  display: flex; flex-direction: column;
  gap: 6px; align-items: center;
  margin-bottom: 28px; padding: 18px 24px;
  background: linear-gradient(135deg, #1a1040, #131329);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.lobby-quiz-name { font-size: 1.2rem; font-weight: 800; color: var(--accent2); }
.lobby-quiz-count { font-size: 0.85rem; color: var(--muted); }
.waiting-indicator {
  display: flex; justify-content: center; gap: 8px;
  margin-bottom: 18px;
}
.waiting-indicator .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}
.waiting-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.waiting-indicator .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse {
  0%,80%,100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.3); }
}

.lobby-title { font-size: 1.4rem; margin-bottom: 6px; font-weight: 800; }
.player-count-big {
  font-size: 2.8rem; font-weight: 900;
  color: var(--accent2);
  margin: 10px 0 24px;
}
.player-count-sep {
  color: var(--muted);
  margin: 0 6px;
  font-weight: 400;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 14px; margin-bottom: 36px;
}
.player-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 10px;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  animation: popIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}
.player-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.player-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.3rem;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.player-card-name {
  font-size: 0.88rem;
  font-weight: 700;
  display: block;
}
.player-card-empty {
  opacity: 0.45;
  border-style: dashed;
}
.player-avatar-empty {
  background: #1a1a35 !important;
  color: var(--muted);
  font-size: 1.4rem;
}
.player-card-name-empty {
  color: var(--muted);
  font-style: italic;
}
.player-disconnected { opacity: 0.5; }
.player-disconnected:hover { opacity: 0.7; }

/* Connection status dots */
.player-avatar-wrapper {
  position: relative;
  display: inline-block;
  margin: 0 auto 10px;
}
.conn-dot {
  position: absolute; bottom: -3px; right: -3px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 3px solid var(--card);
  transition: background 0.3s;
}
.conn-dot-sm {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 0.3s;
}
.conn-online { background: #22c55e; }
.conn-offline { background: #6b7280; }
.you-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.62rem;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 5px;
  font-weight: 700;
}

.btn-start-game {
  padding: 18px 56px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border: none;
  border-radius: 18px;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(139,92,246,0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-start-game:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(139,92,246,0.55);
  background: linear-gradient(135deg, #9f67f8, #8b5cf6);
}
.btn-start-game:active:not(:disabled) {
  transform: translateY(-1px);
}
.btn-start-game:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Countdown */
.countdown-overlay {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #1a1040 0%, #0a0a1a 60%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
}
.countdown-number {
  font-size: 9rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: countBounce 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes countBounce {
  0% { transform: scale(2.2); opacity: 0; }
  60% { transform: scale(0.92); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.countdown-overlay p {
  color: var(--muted);
  font-size: 1.3rem;
  margin-top: 20px;
}

/* Quiz playing — immersion famille */
.room-root.is-immersive,
.room-root.is-playing {
  max-width: 720px;
  width: 100%;
  min-height: 100dvh;
  padding: 8px 12px max(12px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 0%, #1a1040 0%, #0a0a1a 55%);
  overflow-x: clip;
}
.room-topbar-play {
  margin-bottom: 10px;
  gap: 10px;
  flex-wrap: nowrap;
}
.play-hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.play-progress {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  white-space: nowrap;
}
.play-my-score {
  color: var(--accent2);
  font-weight: 800;
  font-size: 0.95rem;
  white-space: nowrap;
}

.play-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  min-height: calc(100dvh - 72px);
}

.score-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 4px 2px 8px;
  margin: 0 -2px;
  scrollbar-width: none;
}
.score-rail::-webkit-scrollbar { display: none; }

.score-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 132px;
  max-width: 180px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(19, 19, 41, 0.95);
  border: 1px solid var(--border);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s, background 0.25s;
}
.score-chip.is-you {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35), 0 6px 18px rgba(139, 92, 246, 0.2);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22), rgba(19, 19, 41, 0.95));
}
.score-chip.is-leader:not(.is-you) {
  border-color: rgba(245, 158, 11, 0.45);
}
.score-chip.has-answered {
  border-color: rgba(34, 197, 94, 0.45);
}
.score-chip.flash-correct {
  animation: chipFlashOk 0.7s ease;
}
.score-chip.flash-wrong {
  animation: chipFlashKo 0.7s ease;
}
@keyframes chipFlashOk {
  0%, 100% { background: rgba(19, 19, 41, 0.95); }
  35% { background: rgba(34, 197, 94, 0.28); }
}
@keyframes chipFlashKo {
  0%, 100% { background: rgba(19, 19, 41, 0.95); }
  35% { background: rgba(239, 68, 68, 0.25); }
}
.score-chip-rank {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  width: 18px;
  flex-shrink: 0;
}
.score-chip.is-leader .score-chip-rank { color: var(--gold); }
.score-chip-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}
.score-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  gap: 1px;
}
.score-chip-name {
  font-size: 0.82rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score-chip-pts {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent2);
}
.score-chip-done {
  color: var(--success);
  font-weight: 900;
  font-size: 1rem;
  flex-shrink: 0;
}

.quiz-play {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 0;
  gap: 10px;
}
.play-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.play-timer-row { width: 100%; }
.play-timer {
  position: relative;
  height: 36px;
  border-radius: 999px;
  background: #12122a;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.play-timer-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  transition: width 1s linear, background 0.3s;
  border-radius: 999px;
}
.play-timer.urgency .play-timer-bar {
  background: linear-gradient(90deg, #ef4444, #f97316);
}
.play-timer-num {
  position: relative;
  z-index: 1;
  font-weight: 900;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.play-timer.urgency .play-timer-num {
  color: #fff;
  animation: urgentPulse 0.5s ease-in-out infinite;
}
.play-reactions {
  margin-top: auto;
  padding-top: 4px;
  padding-bottom: env(safe-area-inset-bottom);
}

.circular-timer {
  position: relative;
  width: 110px;
  height: 110px;
  margin-bottom: 24px;
}
.circular-timer svg {
  width: 100%;
  height: 100%;
}
.timer-circle {
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.3rem;
  font-weight: 900;
  color: #fff;
}
.timer-number.urgency {
  color: var(--danger);
  animation: urgentPulse 0.5s ease-in-out infinite;
}
.timer-number.timer-waiting {
  color: var(--gold);
  animation: waitingPulse 0.8s ease-in-out infinite;
}
@keyframes urgentPulse {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}
@keyframes waitingPulse {
  0%,100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* === Waiting screen (between questions / rejoin) === */
.waiting-screen {
  text-align: center;
  padding-top: 8px;
  animation: cardIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.waiting-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
}
.waiting-screen h2 {
  font-size: 1.45rem;
  margin: 18px 0 10px;
  font-weight: 800;
}
.waiting-sub {
  color: var(--muted);
  font-size: 0.95rem;
}
.waiting-screen .waiting-indicator {
  margin-bottom: 10px;
}

/* === Game in progress banner (join screen) === */
.game-in-progress-banner {
  display: flex; align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #2a1a00, #1a1000);
  border: 1px solid var(--gold);
  border-radius: 16px;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 6px 24px rgba(245,158,11,0.15);
}
.pulse-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.4s ease-in-out infinite;
}

.question-block {
  text-align: center;
  margin-bottom: 4px;
}
.question-num {
  font-size: 0.8rem;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 700;
}
.question-text {
  font-size: clamp(1.2rem, 4.5vw, 1.55rem);
  font-weight: 800;
  margin-top: 0;
  line-height: 1.35;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1a1040;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.choice-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.choice-btn:disabled { cursor: default; }
.choice-btn.selected-correct {
  border-color: var(--success);
  background: #052e16;
  animation: flashGreen 0.5s;
}
.choice-btn.selected-wrong {
  border-color: var(--danger);
  background: #2e0516;
  animation: shake 0.4s;
}
.choice-btn.reveal-correct {
  border-color: var(--success);
  background: #052e16;
}
@keyframes flashGreen {
  0% { background: var(--success); }
  100% { background: #052e16; }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}
.choice-letter {
  background: #1e1e3a;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 1rem;
  color: var(--accent2);
  min-width: 40px;
  text-align: center;
}
.choice-text { flex: 1; }
.check-mark {
  color: var(--success);
  font-weight: 700;
  font-size: 1.4rem;
}

.feedback-toast {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.05rem;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.feedback-toast.correct {
  background: #052e16;
  color: var(--success);
  box-shadow: 0 6px 24px rgba(34,197,94,0.25);
}
.feedback-toast.wrong {
  background: #2e0516;
  color: var(--danger);
  box-shadow: 0 6px 24px rgba(239,68,68,0.25);
}
.fb-icon { font-size: 1.5rem; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.round-reveal {
  text-align: center;
  margin-top: 24px;
  padding: 18px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.correct-answer {
  color: var(--success);
  font-size: 1.25rem;
  font-weight: 700;
}
.next-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
}

.live-ranks {
  width: 100%;
  margin-top: 28px;
  background: var(--card);
  border-radius: 16px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.mini-rank {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.mini-rank:last-child { border-bottom: none; }
.mini-pos {
  font-weight: 800;
  color: var(--accent2);
  width: 26px;
}
.mini-name {
  flex: 1;
  font-size: 0.95rem;
}
.mini-pts { font-weight: 700; color: var(--accent); }
.answered-check {
  font-weight: 800;
  color: #22c55e;
  font-size: 1rem;
}

/* Answer notifications */
.answer-notifications {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 20px;
}

.answer-notification {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  animation: slideInFromTop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.95rem;
  font-weight: 600;
}

@keyframes slideInFromTop {
  0% { opacity: 0; transform: translateY(-20px) scale(0.95); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.answer-notification.correct {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  color: #22c55e;
}

.answer-notification.wrong {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #ef4444;
}

.answer-notification-icon {
  font-size: 1.2rem;
}

/* Finished */
.finished-root {
  text-align: center;
  padding-top: 16px;
  position: relative;
}
.finished-title {
  font-size: 2rem;
  margin-bottom: 36px;
  font-weight: 900;
}

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 36px;
}
.podium-spot {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 18px;
  min-width: 140px;
  animation: podiumRise 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.podium-spot.rank-1 {
  order: 2;
  transform: translateY(-12px);
  background: linear-gradient(180deg, #2a1a00, #1a1000);
  border-color: var(--gold);
  box-shadow: 0 0 36px rgba(245,158,11,0.25), 0 8px 24px rgba(0,0,0,0.3);
}
.podium-spot.rank-2 { order: 1; }
.podium-spot.rank-3 { order: 3; }
@keyframes podiumRise {
  from { opacity: 0; transform: translateY(36px); }
  to { opacity: 1; transform: translateY(-12px); }
}
.podium-spot.rank-2, .podium-spot.rank-3 {
  animation: podiumRise2 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes podiumRise2 {
  from { opacity: 0; transform: translateY(36px); }
  to { opacity: 1; transform: translateY(0); }
}

.podium-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.podium-medal {
  font-size: 2.5rem;
  display: block;
  margin: 6px 0;
}
.podium-name {
  font-weight: 800;
  font-size: 1.05rem;
}
.podium-points {
  color: var(--accent2);
  font-weight: 800;
  font-size: 1rem;
  margin-top: 4px;
}

.full-ranks {
  text-align: left;
  background: var(--card);
  border-radius: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  margin-bottom: 28px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.full-ranks h4 {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 700;
}
.rank-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.rank-row:last-child { border-bottom: none; }
.rank-player {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rank-avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: #fff;
}
.rank-score {
  font-weight: 800;
  color: var(--accent);
}

.btn-home {
  display: inline-block;
  padding: 16px 48px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  border-radius: 16px;
  font-weight: 800;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 6px 24px rgba(139,92,246,0.35);
}
.btn-home:hover {
  background: linear-gradient(135deg, #9f67f8, #8b5cf6);
  transform: translateY(-3px);
  box-shadow: 0 10px 32px rgba(139,92,246,0.5);
}

.finished-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.btn-replay {
  padding: 16px 36px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--success), #16a34a);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 6px 24px rgba(34,197,94,0.4);
}
.btn-replay:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 36px rgba(34,197,94,0.55);
}
.btn-new-theme {
  padding: 16px 36px;
  border: 2px solid var(--accent);
  border-radius: 16px;
  background: transparent;
  color: var(--accent2);
  font-size: 1.1rem;
  font-weight: 800;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-new-theme:hover {
  background: rgba(139,92,246,0.15);
  transform: translateY(-3px);
}

#confetti-canvas, #confetti-canvas-end { position: fixed; inset: 0; z-index: 200; pointer-events: none; display: none; }

/* === Mode badge === */
.room-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mode-badge {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent2);
  padding: 8px 18px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-weight: 800;
}

/* === Solo lobby === */
.solo-hint {
  color: var(--muted);
  font-size: 1rem;
  margin-top: 10px;
}

/* === Bot players === */
.bot-card {
  opacity: 0.75;
  border-color: #f97316 !important;
}
.bot-badge {
  background: #f97316;
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 7px;
  border-radius: 6px;
  margin-left: 5px;
}
.bot-mini { font-size: 0.75rem; }

/* === Share section (viral) === */
.share-section {
  margin: 24px 0;
  padding: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
.share-results {
  margin-top: 24px;
}
.share-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.share-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.share-btn {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.share-btn:hover {
  transform: translateY(-2px);
  opacity: 0.95;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.share-btn.whatsapp {
  background: #25d366;
  color: #fff;
}
.share-btn.twitter {
  background: #000;
  color: #fff;
}
.share-btn.copy-link {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
}
.share-icon {
  font-size: 1.1rem;
}

/* === Invite section (lobby — prominent social CTA) === */
.invite-section {
  margin: 28px 0;
  padding: 24px;
  background: linear-gradient(135deg, #1a1040, #131329);
  border: 1px solid var(--accent);
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(139,92,246,0.2);
}
.invite-title {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.invite-sub {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.invite-code {
  color: var(--accent2);
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 3px;
}

/* === Leave button === */
.btn-leave {
  display: block;
  text-align: center;
  color: var(--muted);
  margin-top: 18px;
  font-size: 0.88rem;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
}
.btn-leave:hover { color: var(--danger); }
.btn-leave-top {
  color: var(--muted);
  text-decoration: none;
  font-size: 1.2rem;
  padding: 6px 12px;
  border-radius: 10px;
  transition: all 0.2s;
  background: none;
  border: none;
  cursor: pointer;
}
.btn-leave-top:hover {
  color: var(--danger);
  background: rgba(239,68,68,0.12);
}

/* === Quiz title hint === */
.quiz-title-hint {
  color: var(--accent2);
  font-size: 0.88rem;
  margin-bottom: 6px;
}

/* === Profile page === */
.profile-card {
  position: relative;
  z-index: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 48px 36px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,0.55), 0 0 90px rgba(139,92,246,0.1);
  animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.profile-header {
  text-align: center;
  margin-bottom: 36px;
}
.profile-avatar-big {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 2rem;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.profile-header h2 {
  font-size: 1.3rem;
  font-weight: 800;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: #0d0d24;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139,92,246,0.2);
}
.stat-value {
  display: block;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent2);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.profile-actions { text-align: center; }

/* === Debug page === */
.debug-card { position: relative; z-index: 1; background: var(--card); border: 1px solid var(--border); border-radius: 24px; padding: 32px 28px; max-width: 720px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: cardIn 0.6s ease-out; }
.debug-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.debug-header h1 { font-size: 1.4rem; }
.debug-badge { background: var(--accent); color: #fff; padding: 3px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; }
.debug-setup { }
.btn-quick-test { width: 100%; padding: 18px; background: linear-gradient(135deg, var(--success), #16a34a); color: #fff; border: none; border-radius: 14px; font-size: 1.1rem; font-weight: 700; cursor: pointer; margin-bottom: 20px; transition: all 0.2s; }
.btn-quick-test:hover { opacity: 0.9; transform: translateY(-1px); }
.debug-cat-list { max-height: 50dvh; overflow-y: auto; }
.debug-cat-section { margin-bottom: 4px; }
.debug-cat-summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #0d0d24; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 0.9rem; transition: border-color 0.15s; list-style: none; }
.debug-cat-summary:hover { border-color: var(--accent); }
.debug-cat-summary::-webkit-details-marker { display: none; }
.debug-cat-icon { font-size: 1.2rem; }
.debug-cat-name { flex: 1; font-weight: 600; }
.debug-cat-count { font-size: 0.7rem; color: var(--muted); background: var(--border); padding: 2px 8px; border-radius: 8px; }
.debug-quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; padding: 8px 0 12px; }
.debug-quiz-btn { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: #0d0d24; border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; font-size: 0.82rem; transition: all 0.15s; text-align: left; }
.debug-quiz-btn:hover { border-color: var(--accent); background: #1a1040; }
.dqb-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.dqb-count { color: var(--muted); font-size: 0.68rem; background: var(--border); padding: 2px 6px; border-radius: 4px; flex-shrink: 0; }
.debug-game { display: flex; flex-direction: column; gap: 20px; }
.debug-bar { background: #0d0d24; border: 1px solid var(--border); border-radius: 12px; padding: 12px 18px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.debug-info { display: flex; gap: 16px; font-size: 0.85rem; color: var(--muted); }
.debug-info strong { color: var(--text); }
.debug-controls { display: flex; gap: 8px; }
.ctrl-btn { padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: #0d0d24; color: var(--text); cursor: pointer; font-size: 0.8rem; transition: all 0.15s; }
.ctrl-btn:hover { border-color: var(--accent); }
.ctrl-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctrl-btn.danger { border-color: var(--danger); color: var(--danger); }
.debug-lobby { text-align: center; }
.debug-lobby h3 { margin-bottom: 16px; }
.player-grid-debug { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px; }
.debug-player { background: #0d0d24; border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; text-align: center; min-width: 90px; }
.debug-player.you { border-color: var(--accent); }
.debug-player.bot { border-color: #f97316; opacity: 0.7; }
.dp-avatar { width: 40px; height: 40px; border-radius: 50%; margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.debug-playing { text-align: center; }
.ext-link { color: var(--accent2); }
.live-scores { background: #0d0d24; border: 1px solid var(--border); border-radius: 14px; padding: 16px; text-align: left; margin-top: 20px; }
.live-scores h4 { margin-bottom: 10px; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
.score-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.score-row:last-child { border-bottom: none; }
.you-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.bot-dot { width: 8px; height: 8px; border-radius: 50%; background: #f97316; }
.sr-name { flex: 1; font-size: 0.9rem; }
.sr-score { font-weight: 700; color: var(--accent); }
.debug-podium { text-align: center; }
.debug-podium h3 { margin-bottom: 14px; }
.debug-rank { display: flex; gap: 12px; padding: 8px 14px; background: #0d0d24; border-radius: 8px; margin-bottom: 6px; text-align: left; align-items: center; }
.dr-pos { font-weight: 700; color: var(--accent2); width: 24px; }
.dr-name { flex: 1; }
.dr-score { font-weight: 700; color: var(--accent); }

.debug-cat-stats { background: #0d0d24; border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 16px; }
.stats-header { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.stat-row { display: flex; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.stat-row:last-child { border-bottom: none; }
.stat-cat { flex: 1; }
.stat-count { font-weight: 700; color: var(--accent2); }

/* Petits écrans / hauteur courte (iPhone SE, landscape) */
@media (max-width: 640px) and (max-height: 700px) {
  .room-root.is-playing .score-rail { display: none; }
  .room-root.is-playing .reaction-bar.play-reactions { display: none; }
  .room-root.is-playing .play-timer { height: 24px; }
  .room-root.is-playing .question-text { font-size: 1rem; }
  .room-root.is-playing .choice-btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.88rem;
  }
  .room-root.is-playing .play-stage { gap: 6px; }
}

/* === Responsive tablet === */
@media (max-width: 820px) {
  .mode-cards { grid-template-columns: 1fr; gap: 10px; }
  .mode-card { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 14px 16px; }
  .home-card { padding: 40px 28px 32px; }
  .create-page { padding: 20px 16px; }
}

/* === Responsive mobile (full) === */
@media (max-width: 640px) {
  .home-root {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    align-items: flex-start;
    padding-top: 16px;
  }
  .home-card { padding: 28px 18px 24px; max-width: 100%; width: 100%; }
  .logo-section { margin-bottom: 20px; }
  .app-title { font-size: clamp(1.85rem, 9vw, 2.2rem); }
  .home-lead { font-size: 0.95rem; }
  .home-paths {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .home-path {
    min-height: 0;
    padding: 16px;
  }
  .home-path-title { font-size: 1.1rem; }
  .code-input-group { border-radius: 14px; }
  .home-join .btn-join {
    min-width: 96px;
    font-size: 0.85rem;
    padding: 0 14px;
  }
  .code-input-group input {
    padding: 16px 12px;
    font-size: clamp(1rem, 4.5vw, 1.25rem);
    letter-spacing: clamp(3px, 1.8vw, 8px);
  }
  .code-input-group input::placeholder {
    letter-spacing: clamp(2px, 1.2vw, 5px);
    font-size: 0.95rem;
  }
  .btn-join {
    min-width: 52px;
    min-height: 52px;
    padding: 0 18px;
  }
  .profile-card { padding: 24px 16px; max-width: 100%; }
  .debug-card { padding: 24px 16px; max-width: 100%; }
  .auth-container {
    min-height: auto;
    padding: 16px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    align-items: flex-start;
  }
  .auth-card { padding: 24px 18px; border-radius: 16px; }
  .auth-card h2 { font-size: 1.3rem; margin-bottom: 18px; }
  .auth-field input { font-size: 16px; padding: 14px 14px; min-height: 48px; }
  .auth-btn { min-height: 48px; font-size: 1rem; }

  .room-root {
    padding: 10px 12px 24px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    min-height: auto;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }
  .room-topbar {
    flex-wrap: nowrap;
    gap: 8px;
    margin-bottom: 14px;
    align-items: center;
  }
  .room-code-box {
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px;
    gap: 8px;
  }
  .code-val {
    font-size: clamp(1rem, 4.5vw, 1.2rem);
    letter-spacing: clamp(2px, 1.2vw, 4px);
  }
  .code-label { font-size: 0.6rem; }
  .room-topbar-right {
    flex: 0 0 auto;
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .mode-badge { display: none; }
  .question-progress {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
  .btn-mute,
  .btn-leave-top {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .join-screen { min-height: auto; padding: 8px 0 24px; }
  .join-card { padding: 28px 18px; border-radius: 20px; }
  .join-card h2 { font-size: 1.35rem; }
  .preview-emoji { font-size: 2.4rem; }
  .avatar-picker { gap: 8px; }
  .avatar-option {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.45rem;
  }

  .player-grid {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
  }
  .player-card { padding: 12px 8px; }
  .player-avatar { width: 44px; height: 44px; font-size: 1.15rem; }
  .player-card-name {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .player-count-big { font-size: 2rem; }
  .btn-start-game {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.05rem;
    min-height: 52px;
  }

  .countdown-number { font-size: clamp(4.5rem, 28vw, 7rem); }

  /* === Quiz play — téléphone immersif === */
  .room-root.is-immersive,
  .room-root.is-playing {
    padding: max(6px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
    max-width: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
  }
  .room-root.is-immersive .room-topbar,
  .room-root.is-playing .room-topbar {
    flex-wrap: nowrap;
    margin-bottom: 6px;
    gap: 8px;
    flex-shrink: 0;
  }
  .room-root.is-immersive .room-topbar-right,
  .room-root.is-playing .room-topbar-right {
    width: auto;
    flex: 0 0 auto;
  }
  .play-hud-left {
    gap: 8px;
    min-width: 0;
  }
  .play-progress {
    font-size: 0.78rem;
    padding: 7px 10px;
  }
  .play-my-score {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .play-stage {
    flex: 1 1 auto;
    min-height: 0;
    gap: 8px;
    display: flex;
    flex-direction: column;
  }
  .score-rail {
    flex-shrink: 0;
    padding: 2px 0 6px;
    margin: 0;
    gap: 6px;
  }
  .score-chip {
    min-width: 104px;
    max-width: 140px;
    padding: 6px 8px;
    gap: 6px;
    border-radius: 14px;
  }
  .score-chip-avatar { width: 30px; height: 30px; font-size: 0.9rem; }
  .score-chip-name { font-size: 0.72rem; }
  .score-chip-pts { font-size: 0.7rem; }
  .score-chip-rank { font-size: 0.65rem; width: 16px; }

  .play-main {
    flex: 1 1 auto;
    min-height: 0;
    gap: 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .play-timer { height: 28px; flex-shrink: 0; }
  .play-timer-num { font-size: 0.88rem; }
  .question-block {
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .question-text {
    font-size: clamp(1.05rem, 4.4vw, 1.28rem);
    line-height: 1.28;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
  }
  .choices {
    gap: 8px;
    flex: 0 0 auto;
  }
  .choice-btn {
    padding: 12px 12px;
    font-size: 0.92rem;
    min-height: 48px;
    gap: 10px;
    border-radius: 14px;
    align-items: flex-start;
  }
  .choice-btn:hover { transform: none; }
  .choice-letter {
    min-width: 32px;
    padding: 5px 8px;
    font-size: 0.9rem;
    margin-top: 1px;
    flex-shrink: 0;
  }
  .choice-text {
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
  }
  .reaction-bar.play-reactions {
    gap: 4px;
    margin-top: 4px;
    padding-bottom: 0;
    flex-shrink: 0;
  }
  .reaction-bar.play-reactions .reaction-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    border-radius: 12px;
  }
  .feedback-toast {
    font-size: 0.9rem;
    padding: 10px 14px;
    margin-top: 0;
  }
  .round-reveal {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
  .correct-answer {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .finished-title { font-size: 1.5rem; margin-bottom: 22px; }
  .finished-hero { font-size: 1.1rem; }
  .podium {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .podium-spot {
    min-width: 0;
    width: 100%;
    padding: 14px 16px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 10px 12px;
    text-align: left;
  }
  .podium-spot.rank-1,
  .podium-spot.rank-2,
  .podium-spot.rank-3 {
    order: 0;
    transform: none;
  }
  .podium-spot.rank-1 { order: -1; }
  .podium-avatar {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
    margin: 0;
    flex-shrink: 0;
  }
  .podium-medal {
    font-size: 1.5rem;
    margin: 0;
    order: -1;
    flex-shrink: 0;
  }
  .podium-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .podium-points {
    margin-top: 0;
    font-size: 0.9rem;
    margin-left: auto;
    flex-shrink: 0;
  }
  .finished-actions {
    flex-direction: column;
    gap: 10px;
  }
  .share-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .share-btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
  .invite-section {
    margin: 16px 0;
    padding: 16px 14px;
  }
  .invite-qr {
    width: 112px;
    height: 112px;
  }
  .btn-replay,
  .btn-new-theme {
    width: 100%;
    min-height: 48px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .modal-card { padding: 20px 16px; max-width: 100%; }
  .mode-cards { grid-template-columns: 1fr; gap: 8px; }
  .mode-card { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 12px 16px; }
  .mode-card-icon { font-size: 1.4rem; }
  .quiz-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .category-grid { grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); }
  .meta-grid { grid-template-columns: 1fr; }
  .count-selector { gap: 6px; }
  .count-btn { padding: 12px; font-size: 1rem; min-height: 44px; }
  .create-page {
    padding: 14px 12px 32px;
    padding-bottom: max(32px, env(safe-area-inset-bottom));
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .seo-theme-page,
  .seo-index-page,
  .legal-page {
    padding: 18px 14px 48px;
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }
  .seo-section,
  .legal-content section { padding: 16px; }
  .seo-cta-row { flex-direction: column; }
  .seo-cta-row .btn-create,
  .seo-cta-row .btn-secondary-outline { width: 100%; min-height: 48px; }
  .join-toast {
    top: calc(64px + env(safe-area-inset-top));
    max-width: calc(100vw - 24px);
    font-size: 0.82rem;
    padding: 10px 14px;
  }
  .site-footer {
    padding: 28px 16px max(24px, env(safe-area-inset-bottom));
  }
  .flash-group,
  [id="flash-group"] {
    left: 12px !important;
    right: 12px !important;
    top: calc(12px + env(safe-area-inset-top)) !important;
    width: auto !important;
  }
}

/* === Social / fun UX additions === */
.btn-mute {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s;
}
.btn-mute:hover { background: rgba(139,92,246,0.18); }
.btn-mute.is-muted { opacity: 0.55; }

.micro-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  display: none;
}

.join-toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  background: linear-gradient(135deg, #1a1040, #131329);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 10px 30px rgba(139,92,246,0.25);
  animation: toastIn 0.35s ease, toastOut 0.35s ease 2.1s forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-8px); }
}

.floating-reactions {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.floating-reaction {
  position: absolute;
  left: var(--rx);
  top: var(--ry);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  animation: floatReact 2.6s ease-out forwards;
}
.floating-reaction-emoji {
  font-size: 2rem;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35));
}
.floating-reaction-name {
  font-size: 0.7rem;
  color: var(--muted);
  background: rgba(10,10,26,0.7);
  padding: 2px 8px;
  border-radius: 999px;
}
@keyframes floatReact {
  0% { opacity: 0; transform: translateY(18px) scale(0.7); }
  15% { opacity: 1; transform: translateY(0) scale(1.05); }
  100% { opacity: 0; transform: translateY(-70px) scale(1); }
}

.reaction-bar {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.reaction-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
}
.reaction-btn:hover {
  transform: translateY(-2px) scale(1.08);
  background: rgba(139,92,246,0.18);
  border-color: var(--accent);
}
.reaction-btn:active { transform: scale(0.94); }

.score-pop {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 75;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--success);
  text-shadow: 0 0 24px rgba(34,197,94,0.45);
  pointer-events: none;
  animation: scorePop 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes scorePop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.5); }
  20% { opacity: 1; transform: translate(-50%, -55%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1); }
}

.player-card.is-you,
.mini-rank.is-you,
.rank-row.is-you,
.podium-spot.is-you {
  border-color: var(--accent2);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.35), 0 8px 24px rgba(139,92,246,0.18);
}
.player-card.is-you {
  background: linear-gradient(180deg, rgba(139,92,246,0.16), rgba(19,19,41,0.9));
}
.mini-rank.is-you,
.rank-row.is-you {
  background: rgba(139,92,246,0.12);
  border-radius: 12px;
}
.you-badge-sm {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent2);
  background: rgba(139,92,246,0.18);
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: middle;
}

.player-card.is-thinking .player-avatar {
  animation: thinkPulse 1.1s ease-in-out infinite;
}
.thinking-bubble {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #f97316;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  animation: thinkBounce 0.9s ease-in-out infinite;
}
.thinking-label {
  margin-left: 6px;
  font-size: 0.7rem;
  color: #fb923c;
  font-weight: 700;
}
@keyframes thinkPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes thinkBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.invite-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 0 auto 16px;
}
.invite-qr {
  width: 148px;
  height: 148px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #131329;
  padding: 8px;
}
.share-btn.native-share {
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #fff;
}

.player-card-empty {
  animation: emptyPulse 2.2s ease-in-out infinite;
}
@keyframes emptyPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.9; }
}

@media (max-width: 640px) {
  .reaction-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
  }
  .invite-qr { width: 120px; height: 120px; }
  .score-pop { font-size: 1.85rem; }
}


/* === Vision francophone / frictionless === */
.home-promise {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--accent2);
  letter-spacing: 0.02em;
}
.play-now-hint {
  text-align: center;
  margin: -8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.btn-secondary-link {
  display: block;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
  padding: 4px 0 2px;
}
.btn-secondary-link:hover { color: var(--accent2); }
.btn-play-now {
  animation: playPulse 2.4s ease-in-out infinite;
}
@keyframes playPulse {
  0%, 100% { box-shadow: 0 10px 28px rgba(139,92,246,0.28); }
  50% { box-shadow: 0 12px 36px rgba(139,92,246,0.45); }
}
.create-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 6px;
}
.cultural-grid .cat-name {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

/* === SEO theme / index pages === */
.seo-theme-page, .seo-index-page {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 64px;
}
.seo-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 22px;
}
.seo-breadcrumb a { color: var(--accent2); text-decoration: none; }
.seo-breadcrumb a:hover { text-decoration: underline; }
.seo-theme-header { text-align: center; margin-bottom: 28px; }
.seo-theme-icon { font-size: 3rem; display: block; margin-bottom: 10px; }
.seo-theme-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
}
.seo-theme-lead {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 540px;
  margin: 0 auto 10px;
}
.seo-theme-meta {
  color: var(--accent2);
  font-size: 0.88rem;
  font-weight: 600;
}
.seo-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 36px;
}
.btn-secondary-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 20px;
  font-weight: 700;
  cursor: pointer;
}
.btn-secondary-outline:hover {
  border-color: var(--accent);
  color: var(--accent2);
}
.seo-section {
  margin-bottom: 32px;
  padding: 22px;
  background: rgba(19,19,41,0.85);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.seo-section h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
}
.seo-section p, .seo-section li {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}
.seo-sample-list {
  list-style: disc;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.seo-note { margin-top: 12px; font-size: 0.82rem !important; opacity: 0.8; }
.seo-steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 8px; }
.seo-theme-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seo-theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(139,92,246,0.12);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}
.seo-theme-chip:hover { border-color: var(--accent); }
.seo-index-cta { text-align: center; margin-top: 28px; }

/* === UX polish (P0–P2) === */
.create-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 28px;
}
.create-header h1 {
  font-size: clamp(1.45rem, 4vw, 1.75rem);
  line-height: 1.2;
}
.create-sub {
  margin-top: 0;
  max-width: 36ch;
}
.create-loading {
  text-align: center;
  color: var(--accent2);
  font-weight: 700;
  margin-bottom: 16px;
}
.category-tile:disabled,
.category-tile.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--border);
}
.category-tile:disabled:hover,
.category-tile.is-disabled:hover {
  border-color: var(--border);
  background: #0d0d24;
  transform: none;
}
.btn-create.is-loading,
.random-tile.is-loading,
.btn-play-now.is-loading {
  opacity: 0.85;
  cursor: wait;
  pointer-events: none;
}
.btn-secondary-link.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}
.connecting-screen {
  text-align: center;
  padding: 64px 20px;
}
.lobby-need-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin: -8px 0 18px;
}
.finished-hero {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent2);
  margin: -8px 0 22px;
}
.live-ranks-collapsible {
  padding: 0;
  overflow: hidden;
}
.live-ranks-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 14px 18px;
  cursor: pointer;
}
.live-ranks-body {
  padding: 0 18px 12px;
}
.room-code-box {
  border: none;
  font: inherit;
  color: inherit;
  text-align: left;
}
/* Scores live toujours visibles via .score-rail — plus de panneau repliable */
@media (prefers-reduced-motion: reduce) {
  .btn-play-now,
  .timer-number.urgency,
  .floating-reaction,
  .join-toast,
  .reed-stem,
  .reed-head,
  .reed-leaf {
    animation: none !important;
  }
  .category-tile,
  .btn-replay,
  .btn-new-theme,
  .share-btn,
  .room-code-box {
    transition: none !important;
  }
}

/* === Site footer + legal pages === */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(10, 10, 26, 0.95);
  padding: 36px 20px 28px;
  margin-top: auto;
}
.site-footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  text-align: center;
}
.site-footer-logo {
  color: var(--accent2);
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
}
.site-footer-tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}
.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
}
.site-footer-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
}
.site-footer-nav a:hover { color: var(--accent2); }
.site-footer-copy {
  color: var(--muted);
  font-size: 0.75rem;
  opacity: 0.75;
}
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* Pendant le quiz : viewport verrouillé (mobile), sans dépendre du root layout */
body:has(.room-root.is-playing) {
  overflow: hidden;
  height: 100dvh;
  height: 100svh;
}
body:has(.room-root.is-playing) > .room-root {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
}
body:has(.room-root.is-playing) [aria-live="polite"] {
  /* flash group — ne pas couvrir le quiz */
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 80;
  pointer-events: none;
}
body > .home-root,
body > .room-root,
body > .legal-page,
body > .seo-theme-root {
  flex: 1 0 auto;
  min-height: 0;
}
.home-root {
  min-height: auto;
}

.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 18px 64px;
  width: 100%;
}
.legal-header {
  margin-bottom: 28px;
}
.legal-header h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 8px;
}
.legal-updated {
  color: var(--muted);
  font-size: 0.85rem;
}
.legal-content section {
  margin-bottom: 26px;
  padding: 20px 22px;
  background: rgba(19, 19, 41, 0.85);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.legal-content h2 {
  font-size: 1.1rem;
  margin-bottom: 10px;
}
.legal-content p,
.legal-content li {
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}
.legal-content ul {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.legal-content a {
  color: var(--accent2);
}
.legal-note {
  margin-top: 12px;
  font-size: 0.85rem !important;
  opacity: 0.85;
}
.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.legal-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.legal-nav a:hover,
.legal-nav a.active {
  color: var(--accent2);
  border-color: var(--accent);
}
