:root {
  --bg: #0b0b14;
  --card-bg: #14141f;
  --text: #f4f4f8;
  --muted: #8a8a9c;
  --accent-a: #ff4d6d;
  --accent-b: #4d7fff;
  --gold: #ffc94d;
  --green: #3ddc84;
  --red: #ff5c5c;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; width: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 77, 109, 0.18), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(77, 127, 255, 0.18), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 28px);
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(11, 11, 20, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  font-size: 15px;
  overflow: hidden;
}
.brand-logo-letter {
  display: inline-block;
  animation: brand-letter-cycle 0.9s ease;
}
@keyframes brand-letter-cycle {
  0% { opacity: 0; transform: translateY(8px) scale(0.7); }
  20% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(0.7); }
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-title { font-weight: 800; font-size: clamp(13px, 3.6vw, 15px); white-space: nowrap; }
.brand-tagline {
  font-size: 8.5px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.app-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.btn-daily {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: clamp(11px, 3vw, 12px);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-daily:hover { border-color: var(--accent-b); }

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.btn-icon:hover { border-color: var(--accent-b); }

.screen { padding-top: clamp(66px, 9vw, 80px) !important; }

.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  z-index: 1;
  position: relative;
  padding: clamp(14px, 4vw, 24px);
}
.screen.active { display: flex; }

.card {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: clamp(28px, 6vw, 40px) clamp(20px, 5vw, 32px);
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  animation: pop-in 0.4s ease;
}

.card-wide { max-width: 640px; }

.quick-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--green);
  margin-bottom: 16px;
}

.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0 20px;
}
.mode-card {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 22px 18px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s, border-color 0.15s;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent-b); }
.mode-card-icon { font-size: 26px; }
.mode-card-title { font-weight: 800; font-size: 16px; }
.mode-card-desc { font-size: 12px; color: var(--muted); line-height: 1.45; }

.mode-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.daily-limit-note {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin: -6px 0 16px;
}
.daily-limit-note.limit-reached { color: var(--red); }

.mode-card.disabled {
  opacity: 0.5;
  pointer-events: none;
}

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

@keyframes pop-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.logo {
  font-size: clamp(22px, 6vw, 28px);
  margin: 0 0 8px;
  line-height: 1.25;
}
.logo span {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { color: var(--muted); font-size: 14px; margin-bottom: 24px; }

.form { display: flex; flex-direction: column; gap: 12px; }

input {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}
input:focus { border-color: var(--accent-b); }

.btn-primary {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  border: none;
  color: white;
  font-weight: 600;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.15s, opacity 0.15s;
  width: 100%;
  display: block;
}
.btn-primary + .btn-primary { margin-top: 10px; }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); opacity: 0.85; }
.btn-primary.btn-secondary {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
}
.btn-primary.btn-secondary:hover { opacity: 0.9; }

.btn-link {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:disabled {
  cursor: default;
  opacity: 0.5;
  text-decoration: none;
}

.email-suggestion {
  display: block;
  width: 100%;
  margin: -6px 0 12px;
  background: rgba(77, 127, 255, 0.1);
  border: 1px dashed rgba(77, 127, 255, 0.35);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.email-suggestion:hover { background: rgba(77, 127, 255, 0.18); }
.email-suggestion strong { color: var(--accent-b); }

.error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
  margin-top: 10px;
}

/* ===== GAME SCREEN ===== */
#screen-game { flex-direction: column; padding: clamp(12px, 4vw, 20px); }
#screen-duel-game { flex-direction: column; padding: clamp(12px, 4vw, 20px); }

.topbar {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: clamp(10px, 1.5vw, 20px);
}

.topbar-panel {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: clamp(12px, 3vw, 18px) clamp(14px, 4vw, 20px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.player-avatar {
  width: clamp(46px, 12vw, 56px);
  height: clamp(46px, 12vw, 56px);
  border-radius: 14px;
  flex-shrink: 0;
  background: linear-gradient(135deg, #5b8dff, #8b6bff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: clamp(15px, 4vw, 18px);
  color: #0b0b14;
}

.player-info {
  flex: 1 1 200px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.status-text { font-size: 11px; color: var(--muted); }

.player-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 480px) {
  .player-badges {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
  }
  .player-badges::-webkit-scrollbar { display: none; }
  .player-badges > * { flex-shrink: 0; }
  .score-badge, .streak-badge, .rank-badge, .level-badge {
    font-size: 10.5px;
    padding: 3px 7px;
    white-space: nowrap;
  }
}

.topbar-panel .xp-bar-wrap { flex-basis: 100%; }

.user-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: clamp(12px, 3.4vw, 14px);
}
.pseudo { font-weight: 700; }
.level-badge {
  background: rgba(255,201,77,0.15);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.streak-badge {
  background: rgba(255,77,109,0.15);
  color: var(--accent-a);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: transform 0.2s;
}
.streak-badge.pulse { animation: pulse 0.4s ease; }
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ===== Tension à 1 vie restante ===== */
body.low-lives::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 45;
  box-shadow: inset 0 0 100px rgba(255,60,60,0.4);
  animation: tense-pulse 1.8s ease-in-out infinite;
}
@keyframes tense-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
body.low-lives .lives-badge {
  animation: pulse 1s ease-in-out infinite;
  display: inline-block;
}
body.low-lives .topbar-panel {
  border-color: rgba(255,92,92,0.35);
}

.xp-bar-wrap { display: flex; align-items: center; gap: 10px; }
.xp-bar {
  flex: 1;
  height: 12px;
  background: #1c1c2a;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-b), var(--green));
  border-radius: 20px;
  transition: width 0.6s cubic-bezier(.22,1,.36,1);
}
.xp-text { font-size: 12px; color: var(--muted); white-space: nowrap; }

.arena {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.4vw, 16px);
}

.round-info-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: clamp(10px, 2.6vw, 12px);
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.round-count-badge {
  background: rgba(255,255,255,0.06);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  text-transform: none;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.domain-tag {
  background: rgba(77,127,255,0.15);
  color: var(--accent-b);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-align: center;
}

.vs-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 4vw, 24px);
  width: 100%;
  margin-top: 12px;
}

.fighter {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 260px;
  background: var(--card-bg);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: clamp(12px, 2.4vw, 20px) clamp(10px, 3vw, 16px);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  text-align: center;
  user-select: none;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.fighter:active { transform: scale(0.97); }
.fighter:hover {
  transform: translateY(-4px);
  border-color: var(--accent-b);
  box-shadow: 0 10px 30px rgba(77,127,255,0.15);
}
.fighter.disabled { pointer-events: none; opacity: 0.6; }
.fighter.disabled.answered { opacity: 1; }
.fighter.correct { border-color: var(--green); box-shadow: 0 0 30px rgba(61,220,132,0.3); }

.winner-pill {
  display: none;
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  background: #0f2318;
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
}
.fighter.correct .winner-pill { display: block; }

.choose-btn {
  margin-top: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text);
  padding: 8px 22px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: none; /* le clic est géré par la carte entière, ce bouton est visuel */
}
.fighter.answered .choose-btn,
.fighter.disabled .choose-btn { display: none; }
.fighter.wrong { border-color: var(--red); }

#fighter-a { animation: slide-left 0.5s cubic-bezier(.22,1,.36,1); }
#fighter-b { animation: slide-right 0.5s cubic-bezier(.22,1,.36,1); }
@keyframes slide-left {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-right {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.avatar {
  width: clamp(56px, 12vw, 72px);
  height: clamp(56px, 12vw, 72px);
  border-radius: 50%;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 700;
  color: white;
  background-color: #2a2a3a;
  background-repeat: no-repeat;
  transition: filter 0.5s ease;
  overflow: hidden;
}

.avatar.loading {
  animation: avatar-pulse 1.1s ease-in-out infinite;
}
@keyframes avatar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.avatar.mystery {
  filter: blur(6px);
}
.avatar.revealing {
  animation: unblur 0.8s ease forwards;
}
@keyframes unblur {
  from { filter: blur(6px); }
  to { filter: blur(0px); }
}

.fighter-name {
  font-size: clamp(14px, 4vw, 17px);
  font-weight: 700;
  margin-bottom: 4px;
  overflow-wrap: break-word;
}
.fighter-name.mystery-text {
  letter-spacing: 3px;
  color: var(--muted);
}
.fighter-domain { font-size: clamp(10px, 3vw, 12px); color: var(--muted); }

.battle-timer {
  width: 100%;
  height: 8px;
  background: #1c1c2a;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
}
.battle-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  border-radius: 20px;
}

.timer-row {
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.timer-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.timer-label-row.centered {
  justify-content: center;
  gap: 6px;
}
.timer-tip {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin: 2px 0 0;
}
.timer-tip kbd {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
}

.next-row {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.next-row .btn-next { flex: 1; margin: 0; max-width: none; min-width: 0; }
.next-row .btn-icon { flex-shrink: 0; }

@media (max-width: 640px) {
  .timer-tip { display: none; }
}

.answer-feedback {
  min-height: 20px;
  text-align: center;
}
.feedback-title {
  font-weight: 800;
  font-size: clamp(15px, 4vw, 18px);
  margin: 0 0 4px;
}
.feedback-title.correct { color: var(--green); }
.feedback-title.wrong { color: var(--gold); }
.feedback-sub {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.vs-badge {
  font-weight: 900;
  font-size: clamp(16px, 4.5vw, 22px);
  color: var(--gold);
  background: #1c1c2a;
  border-radius: 50%;
  width: clamp(40px, 11vw, 52px);
  height: clamp(40px, 11vw, 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: vs-pop 0.5s cubic-bezier(.22,1,.36,1) 0.2s both;
  box-shadow: 0 0 20px rgba(255,201,77,0.25);
}
@keyframes vs-pop {
  from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.hint {
  font-size: 13px;
  color: var(--gold);
  min-height: 18px;
  text-align: center;
}

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

.btn-next {
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  border: none;
  color: white;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s;
  width: 100%;
  max-width: 320px;
  touch-action: manipulation;
}
.btn-next:hover { transform: translateY(-2px); }
.btn-next:active { transform: translateY(0) scale(0.98); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.1);
  padding: 12px 22px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  transition: transform 0.3s ease;
  z-index: 10;
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .vs-wrap { flex-direction: row; align-items: center; gap: 8px; }
  .fighter { max-width: none; padding: 14px 8px; }
  .fighter:hover { transform: none; }
}

@media (max-width: 400px) {
  .card { padding: 24px 16px; }
  .avatar { width: 56px; height: 56px; }
  .user-info { justify-content: center; }
  .level-badge, .streak-badge { padding: 3px 8px; font-size: 11px; }
  .vs-wrap { gap: 6px; }
  .fighter { padding: 12px 6px; }
  .vs-badge { width: 32px; height: 32px; font-size: 14px; }
  .next-row .btn-next { padding: 14px 12px; font-size: 13px; }
}

@media (hover: none) {
  .fighter:hover { transform: none; border-color: rgba(255,255,255,0.06); box-shadow: none; }
  .btn-primary:hover, .btn-next:hover { transform: none; }
}

/* "Battle suivante" + le "?" restent collés ensemble, fixés en bas sur mobile */
@media (max-width: 640px) {
  .arena { padding-bottom: 88px; }

  .next-row {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    max-width: none;
    margin: 0 auto;
    z-index: 20;
  }
  .next-row .btn-next {
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  }
  .btn-next:active { transform: scale(0.98); }
}

/* ===== AJOUTS : rang, score, vies, banners, résultat compact, game over ===== */

.rank-badge {
  background: rgba(255,255,255,0.06);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.run-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: clamp(12px, 3.4vw, 14px);
  font-weight: 700;
}

.score-badge {
  background: rgba(255,201,77,0.15);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 13px;
}

.lives-badge {
  font-size: 15px;
  letter-spacing: 2px;
}

/* ===== Bannière de mode (mystère / légendaire / jackpot) ===== */
.mode-banner {
  text-align: center;
  padding: 10px 18px;
  border-radius: 14px;
  font-weight: 800;
  font-size: clamp(13px, 3.8vw, 16px);
  letter-spacing: 0.5px;
  animation: banner-in 0.35s ease;
}
.mode-banner.mystery {
  background: rgba(77,127,255,0.12);
  color: #9fb8ff;
  border: 1px solid rgba(77,127,255,0.3);
}
.mode-banner.legendary {
  background: rgba(255,201,77,0.12);
  color: var(--gold);
  border: 1px solid rgba(255,201,77,0.35);
  animation: banner-in 0.35s ease, glow-pulse 1.6s ease-in-out infinite;
}
.mode-banner.jackpot {
  background: linear-gradient(90deg, rgba(255,77,109,0.18), rgba(77,127,255,0.18));
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  animation: banner-in 0.35s ease, glow-pulse 1s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255,201,77,0.15); }
  50% { box-shadow: 0 0 24px rgba(255,201,77,0.45); }
}

.mode-banner .banner-sub {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
  letter-spacing: 0.3px;
}

/* Icône de catégorie affichée à la place de l'avatar en mode mystère */
/* ===== Bannière "série perdue" ===== */
.streak-lost-banner {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-40px);
  opacity: 0;
  background: linear-gradient(90deg, rgba(255,92,92,0.95), rgba(255,77,109,0.95));
  color: white;
  padding: 12px 22px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.streak-lost-banner.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.streak-lost-banner .sub {
  display: block;
  font-weight: 500;
  font-size: 11px;
  opacity: 0.9;
  margin-top: 2px;
}

/* ===== Game Over (pensé pour être capturé/partagé) ===== */
.gameover-card {
  background: radial-gradient(circle at 50% 0%, rgba(255,77,109,0.12), transparent 60%), var(--card-bg);
  border: 1px solid rgba(255,255,255,0.08);
}
.gameover-mood {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 4px;
  animation: pop-in 0.4s ease;
}
.gameover-title { color: var(--red); margin-bottom: 6px; }
.gameover-message {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 22px;
  line-height: 1.5;
}

.gameover-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.gameover-stat {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gameover-stat-value {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 900;
  color: var(--gold);
}
.gameover-stat-label {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 700;
}

/* ===== Coffre de passage de rang ===== */
.chest-box {
  background: var(--card-bg);
  border: 1px solid rgba(255,201,77,0.3);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(255,201,77,0.15);
  animation: pop-in 0.3s ease;
}
.chest-title {
  font-weight: 800;
  font-size: 15px;
  margin: 0 0 6px;
  color: var(--text);
}
.chest-rank {
  font-weight: 900;
  font-size: 20px;
  color: var(--gold);
  margin: 0 0 20px;
}
.chest-icon {
  background: none;
  border: none;
  font-size: 76px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  animation: chest-idle 1.6s ease-in-out infinite;
  transition: transform 0.2s ease;
}
.chest-icon:disabled { cursor: default; }
.chest-icon.opened {
  animation: chest-pop 0.4s ease forwards;
}
@keyframes chest-idle {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.06) rotate(-3deg); }
}
@keyframes chest-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3) rotate(8deg); }
  100% { transform: scale(1.15) rotate(0deg); }
}
.chest-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 0;
}
.chest-reward {
  font-size: 22px;
  font-weight: 900;
  color: var(--green);
  margin: 16px 0 0;
  animation: pop-in 0.3s ease;
}

/* ===== Popup infos battle ("?") ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 5, 10, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 4vw, 24px);
}
.modal-box {
  position: relative;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  padding: clamp(20px, 5vw, 28px);
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: pop-in 0.25s ease;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.08);
  border: none;
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.modal-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 6px;
}
@media (max-width: 520px) {
  .modal-content { grid-template-columns: 1fr; }
}
.modal-card {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 16px;
  text-align: left;
}
.modal-card.winner { border-color: rgba(61,220,132,0.4); }
.modal-card-name {
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 2px;
}
.modal-card-domain {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}
.modal-card-bio {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

/* ===== Menu profil (historique + déconnexion) ===== */
.account-wrap { position: relative; }

.btn-account {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text);
  padding: 6px 12px 6px 6px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.btn-account:hover { border-color: var(--accent-b); }

.account-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b8dff, #8b6bff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 11px;
  color: #0b0b14;
  flex-shrink: 0;
}
#account-avatar-big { width: 40px; height: 40px; font-size: 15px; }

.account-label {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, 88vw);
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  z-index: 60;
  animation: pop-in 0.2s ease;
}

.account-dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}
.account-dropdown-identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.account-dropdown-email {
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.account-dropdown-xp {
  font-weight: 700;
  font-size: 11px;
  color: var(--gold);
}
.account-dropdown-next-rank {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}

.account-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.history-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.history-empty {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 10px 0;
  margin: 0;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #1c1c2a;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.history-item .history-names {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.history-item .history-result {
  font-weight: 800;
  flex-shrink: 0;
}
.history-item.win .history-result { color: var(--green); }
.history-item.loss .history-result { color: var(--red); }

.btn-logout {
  width: 100%;
  background: rgba(255,92,92,0.12);
  border: 1px solid rgba(255,92,92,0.35);
  color: var(--red);
  padding: 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}
.btn-logout:hover { background: rgba(255,92,92,0.2); }

/* ===== Classement (popup) ===== */
.leaderboard-back {
  margin-top: 18px;
}

.leaderboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 18px;
}
.filter-btn {
  background: #1c1c2a;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.filter-btn.active {
  background: rgba(77,127,255,0.18);
  border-color: var(--accent-b);
  color: var(--text);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: none;
}
.leaderboard-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #1c1c2a;
  border-radius: 10px;
  padding: 10px 14px;
}
.leaderboard-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.leaderboard-row-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 11px;
  color: var(--muted);
  padding-left: 40px;
}
.leaderboard-rank {
  font-weight: 900;
  color: var(--muted);
  width: 28px;
  flex-shrink: 0;
  text-align: center;
}
.leaderboard-row.top1 .leaderboard-rank { color: var(--gold); }
.leaderboard-row.top2 .leaderboard-rank { color: #c9c9d4; }
.leaderboard-row.top3 .leaderboard-rank { color: #c98a4b; }
.leaderboard-pseudo {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-xp {
  font-weight: 800;
  color: var(--gold);
  font-size: 13px;
  flex-shrink: 0;
}
.leaderboard-me { border: 1px solid var(--accent-b); }

/* ===== Menu compact mobile (Classement / Défi du jour / Aide) ===== */
.mobile-menu-wrap { position: relative; display: none; }

.mobile-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 6px;
  z-index: 70;
  box-shadow: 0 15px 40px rgba(0,0,0,0.5);
  animation: pop-in 0.2s ease;
}
.mobile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.mobile-menu-item:hover { background: rgba(255,255,255,0.06); }

@media (max-width: 640px) {
  .desktop-only-action { display: none; }
  .mobile-menu-wrap { display: block; }
}

/* Header compact sur mobile : évite tout débordement horizontal, qui décale
   ensuite les éléments position:fixed (bouton Battle suivante, "?") hors écran. */
@media (max-width: 480px) {
  .brand-tagline { display: none; }
  .account-label { max-width: 70px; }
  .app-header { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .app-header-actions { gap: 6px; }
}

/* ===== Écran de chargement ===== */
.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--accent-b);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
