/* --- Variables (ambiance Pokémon-like, sans assets officiels) --- */
:root {
  --bg-top: #1e3a5f;
  --bg-bottom: #0f172a;
  --card: #ffffff;
  --card-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  --accent: #f59e0b;
  --accent-soft: #fef3c7;
  --red: #ef4444;
  --red-soft: #fee2e2;
  --green: #22c55e;
  --green-soft: #dcfce7;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 16px;
  --radius-sm: 12px;
  --font: 'Outfit', system-ui, sans-serif;
  --font-display: 'Nunito', var(--font);
  --indigo: #6366f1;
  --indigo-soft: #e0e7ff;
  --violet-glow: rgba(99, 102, 241, 0.35);
  --red-deep: #7f1d1d;
  /* Panneaux sur fond dégradé (grille, progression, modal) */
  --panel-surface: linear-gradient(
    165deg,
    rgba(51, 65, 85, 0.94) 0%,
    rgba(30, 41, 59, 0.97) 45%,
    rgba(15, 23, 42, 0.98) 100%
  );
  --panel-border: rgba(148, 163, 184, 0.28);
  --panel-inset: rgba(255, 255, 255, 0.07);
  --panel-text: #f1f5f9;
  --panel-text-soft: rgba(203, 213, 225, 0.92);
  --panel-muted: rgba(148, 163, 184, 0.95);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(165deg, var(--bg-top) 0%, var(--bg-bottom) 55%, #020617 100%);
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(251, 191, 36, 0.15), transparent),
    radial-gradient(circle at 10% 90%, rgba(59, 130, 246, 0.12), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(239, 68, 68, 0.1), transparent 35%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: min(1180px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1.35rem 0.75rem 2.75rem;
}

/* --- Header --- */
.hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.hero__badge {
  display: inline-block;
  margin: 0 0 0.5rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-soft);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hero__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  letter-spacing: -0.02em;
}

.hero__auth {
  margin-top: 1.1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* Compte / classement : colonne gauche au-dessus des règles */
.hero__auth--sidebar {
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  max-width: none;
  text-align: left;
}

.hero__auth-hint {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.4;
}

.hero__auth--sidebar .hero__auth-hint {
  margin-bottom: 0.75rem;
}

.hero__auth-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.hero__auth--sidebar .hero__auth-buttons {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.5rem;
}

.hero__auth--sidebar .hero__auth-buttons .btn--compact {
  width: 100%;
  justify-content: center;
}

.hero__auth-badge {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.9);
  margin-right: 0.25rem;
}

.hero__auth--sidebar .hero__auth-badge {
  display: block;
  margin-right: 0;
  margin-bottom: 0.15rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.hero__auth-badge strong {
  color: #fff;
  font-weight: 800;
}

.btn--compact {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.auth-modal__tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.auth-modal__tab {
  flex: 1;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.5);
  color: var(--panel-text-soft);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.auth-modal__tab[aria-selected='true'] {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
}

.auth-modal__error {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: #fecaca;
  background: rgba(127, 29, 29, 0.45);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 10px;
}

.auth-modal__form .modal__field-label {
  margin-top: 0.5rem;
}

.auth-modal__form .modal__field-label:first-child {
  margin-top: 0;
}

.auth-modal__lead {
  margin-top: 0;
  margin-bottom: 0.85rem;
}

.auth-modal__loading,
.auth-modal__empty {
  margin: 0;
  font-size: 0.92rem;
  color: var(--panel-text-soft);
}

/* --- Classement (carte immersive) --- */
.lb-dialog {
  border: none;
  padding: 0;
  margin: auto;
  max-width: calc(100vw - 1.25rem);
  background: transparent;
}

.lb-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
}

.lb-shell {
  padding: 0.5rem;
}

.lb-card {
  width: min(26rem, calc(100vw - 1.5rem));
  padding: 24px;
  border-radius: 20px;
  background: linear-gradient(145deg, #0f172a 0%, #1e293b 48%, #0f172a 100%);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(99, 102, 241, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.lb-header {
  text-align: center;
  margin-bottom: 1.1rem;
}

.lb-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 20px rgba(99, 102, 241, 0.35);
}

.lb-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.95);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lb-list-scroll {
  min-height: 5rem;
  max-height: min(46vh, 22rem);
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -4px;
  padding: 4px 6px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(129, 140, 248, 0.55) rgba(15, 23, 42, 0.45);
}

.lb-list-scroll::-webkit-scrollbar {
  width: 8px;
}

.lb-list-scroll::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.45);
  border-radius: 8px;
}

.lb-list-scroll::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.65), rgba(99, 102, 241, 0.45));
  border-radius: 8px;
}

@keyframes lbRowIn {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.lb-row {
  --lb-i: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  color: #f1f5f9;
  animation: lbRowIn 0.48s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--lb-i) * 0.045s);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    filter 0.2s ease;
}

.lb-row:last-child {
  margin-bottom: 0;
}

.lb-row--gold {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.35) 0%, rgba(120, 53, 15, 0.45) 100%);
  border-color: rgba(250, 204, 21, 0.45);
  box-shadow:
    0 0 24px rgba(250, 204, 21, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.lb-row--silver {
  background: linear-gradient(135deg, rgba(203, 213, 225, 0.28) 0%, rgba(71, 85, 105, 0.4) 100%);
  border-color: rgba(226, 232, 240, 0.35);
  box-shadow:
    0 0 18px rgba(226, 232, 240, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.lb-row--bronze {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.35) 0%, rgba(67, 20, 7, 0.42) 100%);
  border-color: rgba(251, 146, 60, 0.35);
  box-shadow:
    0 0 18px rgba(251, 146, 60, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lb-row--rest {
  background: rgba(15, 23, 42, 0.55);
}

.lb-row--rest:hover {
  transform: scale(1.02);
  border-color: rgba(129, 140, 248, 0.35);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.lb-row--gold:hover,
.lb-row--silver:hover,
.lb-row--bronze:hover {
  transform: scale(1.02);
  filter: brightness(1.06);
}

.lb-row__rank {
  flex: 0 0 auto;
  min-width: 3.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: rgba(248, 250, 252, 0.95);
  font-size: 0.88rem;
}

.lb-row__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-row__stats {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.92);
}

.lb-stat {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.lb-empty,
.lb-loading {
  margin: 0;
  padding: 1.25rem 0.5rem;
  text-align: center;
  font-size: 0.92rem;
  color: rgba(148, 163, 184, 0.95);
  line-height: 1.5;
}

.lb-footer {
  margin-top: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.lb-share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lb-share-row .lb-btn {
  flex: 1 1 auto;
  min-width: 8rem;
}

.lb-share-feedback {
  margin: 0;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #4ade80;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.45);
}

.lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 1rem;
  border-radius: 14px;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    filter 0.18s ease,
    opacity 0.18s ease;
}

.lb-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.lb-btn--primary {
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow:
    0 4px 0 #3730a3,
    0 12px 32px rgba(99, 102, 241, 0.35);
}

.lb-btn--primary:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow:
    0 4px 0 #3730a3,
    0 16px 40px rgba(99, 102, 241, 0.45);
}

.lb-btn--ghost {
  background: rgba(30, 41, 59, 0.85);
  color: #e2e8f0;
  border: 2px solid rgba(148, 163, 184, 0.35);
}

.lb-btn--ghost:hover:not(:disabled) {
  border-color: rgba(129, 140, 248, 0.55);
  background: rgba(51, 65, 85, 0.95);
}

.lb-btn--close {
  background: rgba(15, 23, 42, 0.75);
  color: #cbd5e1;
  border: 2px solid rgba(148, 163, 184, 0.28);
}

.lb-btn--close:hover:not(:disabled) {
  border-color: rgba(203, 213, 225, 0.45);
  color: #f1f5f9;
  box-shadow: 0 0 20px rgba(148, 163, 184, 0.15);
}

.lb-btn--primary:active:not(:disabled),
.lb-btn--ghost:active:not(:disabled),
.lb-btn--close:active:not(:disabled) {
  transform: scale(0.98);
}

.hero__subtitle {
  margin: 0.75rem auto 0;
  max-width: 36rem;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.88);
}

.hero__hint {
  margin: 0.65rem auto 0;
  max-width: 32rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.65);
}

.hero__subtitle strong,
.hero__hint strong {
  color: #fde68a;
  font-weight: 700;
}

/* --- Panels --- */
.panel {
  text-align: center;
  padding: 2rem 1.25rem;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--card-shadow);
}

.panel--loading {
  color: var(--text-muted);
}

.panel--error {
  border: 2px solid var(--red-soft);
  background: #fff;
}

.panel--error #error-text {
  margin: 0 0 1rem;
  color: var(--red);
  font-weight: 600;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Card & board --- */
.game-root {
  animation: fadeIn 0.45s ease-out;
}

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

/* --- Coque jeu : règles | plateau | progression --- */
.game-shell {
  display: grid;
  gap: 1.25rem;
}

.game-shell__left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

@media (min-width: 960px) {
  .game-shell {
    grid-template-columns: minmax(232px, 270px) minmax(480px, 1fr) minmax(168px, 204px);
    align-items: start;
    gap: 1.35rem 1.5rem;
  }
}

.game-shell__rules {
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.16) 0%,
    rgba(255, 255, 255, 0.07) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.2);
  color: rgba(255, 255, 255, 0.94);
}

.game-shell__rules-lead {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.game-shell__rules-hint {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
}

.game-shell__rules-lead strong,
.game-shell__rules-hint strong {
  color: #fde68a;
  font-weight: 700;
}

.game-shell__board {
  min-width: 0;
}

.game-shell__aside {
  justify-self: stretch;
}

.aside-card {
  padding: 1rem 1rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--panel-surface);
  box-shadow:
    0 16px 44px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 var(--panel-inset);
  border: 1px solid var(--panel-border);
  text-align: center;
}

.aside-card__label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--panel-muted);
}

.aside-card__count {
  margin: 0.35rem 0 0.15rem;
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--panel-text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.aside-card__sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--panel-text-soft);
}

.card {
  background: var(--panel-surface);
  border-radius: var(--radius);
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 var(--panel-inset);
  padding: 1rem 0.75rem 1.25rem;
  border: 1px solid var(--panel-border);
}

@media (min-width: 640px) {
  .card {
    padding: 1.35rem 1.25rem 1.5rem;
  }
}

.board {
  display: grid;
  grid-template-columns: minmax(5rem, 0.95fr) repeat(3, 1fr);
  grid-template-rows: auto repeat(3, minmax(7rem, 1fr));
  gap: 0.5rem;
  align-items: stretch;
}

@media (min-width: 640px) {
  .board {
    grid-template-columns: minmax(7.75rem, 1.12fr) repeat(3, 1fr);
    grid-template-rows: auto repeat(3, minmax(7.75rem, 1fr));
    gap: 0.65rem;
  }
}

@media (min-width: 900px) {
  .board {
    grid-template-columns: minmax(8.5rem, 1.15fr) repeat(3, minmax(0, 1fr));
    grid-template-rows: auto repeat(3, minmax(8.25rem, 1fr));
    gap: 0.72rem;
  }
}

.board__corner {
  grid-column: 1;
  grid-row: 1;
}

.board__col-headers {
  grid-column: 2 / -1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: inherit;
}

.board__row-headers {
  grid-column: 1;
  grid-row: 2 / -1;
  display: grid;
  grid-template-rows: repeat(3, 1fr);
  gap: inherit;
}

.board__cells {
  grid-column: 2 / -1;
  grid-row: 2 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: inherit;
}

.theme-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.45rem 0.35rem;
  font-size: clamp(0.68rem, 2.2vw, 0.82rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  background: linear-gradient(145deg, var(--blue-soft), #eff6ff);
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
  min-height: 3rem;
}

.theme-tag--row {
  background: linear-gradient(145deg, var(--accent-soft), #fff7ed);
  border-color: #fcd34d;
}

.theme-tag--col {
  background: linear-gradient(145deg, #e0e7ff, #eef2ff);
  border-color: #c7d2fe;
}

.theme-tag--lit {
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.55),
    0 4px 14px rgba(59, 130, 246, 0.2);
  transform: scale(1.02);
  transition:
    box-shadow 0.25s ease,
    transform 0.25s ease;
}

/* --- Badges thème (en-têtes grille + modal) : classes = ThemeBadge.js --- */
.badge {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3rem;
  padding: 0.5rem 0.45rem;
  font-size: clamp(0.65rem, 2vw, 0.82rem);
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
  border-radius: var(--radius-sm);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 14px rgba(15, 23, 42, 0.14);
}

.badge.feu {
  background: linear-gradient(145deg, #f97316, #c2410c);
  border-color: #fdba74;
}
.badge.eau {
  background: linear-gradient(145deg, #38bdf8, #0284c7);
  border-color: #7dd3fc;
}
.badge.plante {
  background: linear-gradient(145deg, #4ade80, #15803d);
  border-color: #86efac;
}
.badge.electrik {
  background: linear-gradient(145deg, #facc15, #ca8a04);
  color: #1c1917;
  text-shadow: none;
}
.badge.glace {
  background: linear-gradient(145deg, #67e8f9, #0891b2);
  border-color: #a5f3fc;
}
.badge.normal {
  background: linear-gradient(145deg, #94a3b8, #64748b);
}
.badge.combat {
  background: linear-gradient(145deg, #f87171, #b91c1c);
  border-color: #fecaca;
}
.badge.psy {
  background: linear-gradient(145deg, #e879f9, #a21caf);
  border-color: #f0abfc;
}
.badge.tenebres {
  background: linear-gradient(145deg, #57534e, #1c1917);
  border-color: #78716c;
}
.badge.poison {
  background: linear-gradient(145deg, #c084fc, #7e22ce);
  border-color: #e9d5ff;
}
.badge.sol {
  background: linear-gradient(145deg, #d97706, #92400e);
  border-color: #fcd34d;
}
.badge.vol {
  background: linear-gradient(145deg, #818cf8, #4338ca);
  border-color: #c7d2fe;
}
.badge.insecte {
  background: linear-gradient(145deg, #84cc16, #4d7c0f);
  border-color: #bef264;
}
.badge.roche {
  background: linear-gradient(145deg, #a8a29e, #57534e);
  border-color: #d6d3d1;
}
.badge.spectre {
  background: linear-gradient(145deg, #7c3aed, #4c1d95);
  border-color: #c4b5fd;
}
.badge.dragon {
  background: linear-gradient(145deg, #6366f1, #312e81);
  border-color: #a5b4fc;
}
.badge.fee {
  background: linear-gradient(145deg, #f472b6, #be185d);
  border-color: #fbcfe8;
}
.badge.acier {
  background: linear-gradient(145deg, #94a3b8, #475569);
  border-color: #cbd5e1;
}
.badge.stats {
  background: linear-gradient(145deg, #f59e0b, #b45309);
  border-color: #fde68a;
}
.badge.gen {
  background: linear-gradient(145deg, #14b8a6, #0f766e);
  border-color: #5eead4;
}
.badge.autre {
  background: linear-gradient(145deg, #64748b, #334155);
  border-color: #cbd5e1;
}

/* --- Bandeau catalogue (suggestions indisponibles) --- */
.catalog-warning {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.12);
  color: var(--text);
}

.catalog-warning[hidden] {
  display: none !important;
}

.catalog-warning__icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.catalog-warning__body {
  min-width: 0;
}

.catalog-warning__title {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  color: #92400e;
  margin: 0 0 0.35rem;
}

.catalog-warning__sub {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: #78350f;
}

.catalog-warning__sub strong {
  font-weight: 700;
  color: #451a03;
}

/* --- Victory chip (après fermeture overlay) --- */
.victory-chip {
  margin: 0 0 1rem;
  padding: 0.55rem 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #14532d;
  background: linear-gradient(90deg, #dcfce7, #d1fae5);
  border: 1px solid #86efac;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.15);
}

/* --- Cell --- */
.cell {
  position: relative;
  z-index: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.55rem;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease,
    transform 0.2s ease,
    z-index 0s;
}

/* Case au focus : passer au-dessus des voisines + laisser le panneau déborder */
.cell:focus-within {
  z-index: 200;
  overflow: visible;
  border-color: var(--indigo);
  box-shadow:
    0 0 0 3px rgba(99, 102, 241, 0.28),
    0 8px 26px rgba(99, 102, 241, 0.14);
}

@media (hover: hover) {
  .cell:not(:disabled):not(.cell--success):hover {
    background: linear-gradient(180deg, #eef2ff 0%, #e0e7ff 100%);
    border-color: #a5b4fc;
    transform: scale(1.03);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.92),
      0 8px 22px rgba(99, 102, 241, 0.22);
  }
}

.cell:focus-visible {
  outline: none;
  border-color: var(--indigo);
  box-shadow:
    0 0 0 3px rgba(99, 102, 241, 0.42),
    0 8px 24px rgba(99, 102, 241, 0.16);
}

.cell--success {
  cursor: default;
  color: #fff;
  background: linear-gradient(160deg, #22c55e, #15803d);
  border-color: #4ade80;
  box-shadow:
    0 0 24px rgba(74, 222, 128, 0.45),
    0 4px 16px rgba(34, 197, 94, 0.35);
}

.cell:disabled {
  cursor: default;
}

.cell__surface {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.35rem;
}

.cell__sprite {
  display: none;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.cell--success .cell__sprite {
  display: flex;
}

.cell__sprite img {
  width: min(76px, 24vw);
  height: min(76px, 24vw);
  object-fit: contain;
  image-rendering: pixelated;
  animation: spriteIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

@keyframes spriteIn {
  from {
    opacity: 0;
    transform: scale(0.35) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.cell__pokemon-name {
  display: none;
  font-size: clamp(0.62rem, 2.4vw, 0.78rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  padding: 0 0.15rem;
  max-width: 100%;
  word-break: break-word;
}

.cell--success .cell__pokemon-name {
  display: block;
}

.cell__hint {
  font-size: clamp(0.55rem, 2vw, 0.68rem);
  font-weight: 600;
  color: #64748b;
  text-align: center;
  line-height: 1.25;
  padding: 0 0.2rem;
}

.cell--success .cell__hint {
  display: none !important;
}

.cell__check-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  color: #15803d;
  background: #fff;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cell__check-badge[hidden] {
  display: none !important;
}

.cell--success .cell__input:disabled {
  background: transparent;
  border-color: transparent;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #065f46;
  padding: 0.1rem 0.4rem;
  min-height: unset;
}

.cell--success .cell__actions {
  justify-content: center;
}

.cell--error {
  border-color: rgba(239, 68, 68, 0.85) !important;
  background: linear-gradient(180deg, #fef2f2 0%, #fee2e2 100%) !important;
}

.cell--error-flash {
  animation: errorFlash 0.45s ease;
}

@keyframes errorFlash {
  0%,
  100% {
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.08);
  }
  40% {
    box-shadow:
      0 0 0 3px rgba(239, 68, 68, 0.55),
      0 0 28px rgba(239, 68, 68, 0.3),
      inset 0 2px 12px rgba(0, 0, 0, 0.08);
  }
}

.cell__input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  min-height: 2.65rem;
  font-size: 0.95rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.cell__input:hover:not(:disabled) {
  border-color: #cbd5e1;
}

.cell__input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.cell__input:disabled {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  font-weight: 600;
  cursor: not-allowed;
  opacity: 1;
}

.cell__input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.cell__actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cell__check {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  color: #16a34a;
  background: rgba(34, 197, 94, 0.12);
  border-radius: 10px;
  border: 1px solid #bbf7d0;
}

.cell__check[hidden] {
  display: none !important;
}

.cell__check-icon {
  display: block;
}

.cell__btn {
  flex: 1;
  min-height: 2.65rem;
  padding: 0.5rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  background: linear-gradient(180deg, var(--blue), #2563eb);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 0 #1d4ed8;
  transition:
    transform 0.12s,
    filter 0.12s;
}

.cell__btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.cell__btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #1d4ed8;
}

.cell__btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.cell--shake {
  animation: shake 0.15s ease-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  33% {
    transform: translateX(-4px);
  }
  66% {
    transform: translateX(4px);
  }
}

.cell--pop {
  animation: pop 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.cell--glow {
  animation: cellGlow 0.55s ease-out;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cellGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
  }
  100% {
    box-shadow: 0 0 0 12px transparent;
  }
}

/* --- Saisie intelligente (ancré dans .cell active, position absolute CSS) --- */
.pg-suggest {
  position: absolute;
  top: calc(100% + 4px); /* juste sous la cellule */
  left: 0;
  right: 0;
  z-index: 9999;
  box-sizing: border-box;
  margin: 0;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  border: 2px solid var(--indigo);
  border-radius: 12px;
  box-shadow:
    0 12px 40px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(99, 102, 241, 0.18);
}

.pg-suggest[hidden] {
  display: none !important;
}

/* Suggestions modal : fixed dans le viewport, attaché au <dialog> (top layer) */
.pg-suggest.pg-suggest--dialog-floating {
  position: fixed;
  left: auto;
  right: auto;
  top: auto;
  z-index: 2;
}

.pg-suggest__option {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.65rem;
  text-align: left;
  font-size: 0.92rem;
  font-family: var(--font);
  color: var(--text);
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: transparent;
  transition: background 0.12s ease;
}

.pg-suggest__option:hover,
.pg-suggest__option:focus-visible {
  outline: none;
  background: var(--blue-soft);
}

.pg-suggest__option--active {
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.pg-suggest__mark {
  padding: 0 0.05em;
  font-weight: 800;
  color: var(--text);
  background: rgba(251, 191, 36, 0.45);
  border-radius: 3px;
}

/* --- Feedback --- */
.feedback {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.feedback[data-type='ok'] {
  background: var(--green-soft);
  color: #166534;
  border: 1px solid #bbf7d0;
}

.feedback[data-type='error'] {
  background: var(--red-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.feedback[data-type='warn'] {
  background: var(--accent-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}

.feedback[data-type='info'] {
  background: var(--blue-soft);
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* --- Actions --- */
.actions {
  margin-top: 1.25rem;
  text-align: center;
}

.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition:
    transform 0.12s,
    filter 0.12s,
    box-shadow 0.12s;
}

.btn--secondary {
  background: #334155;
  color: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.btn--secondary:hover {
  filter: brightness(1.1);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn--outline {
  background: #fff;
  color: var(--text);
  border: 2px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.btn--outline:hover {
  border-color: var(--blue);
  color: #1d4ed8;
}

.btn--giveup {
  width: 100%;
  background: linear-gradient(180deg, #ef4444, var(--red-deep));
  color: #fff;
  border: 2px solid rgba(248, 113, 113, 0.55);
  box-shadow:
    0 4px 0 rgba(127, 29, 29, 0.85),
    0 8px 24px rgba(239, 68, 68, 0.25);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.btn--giveup:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn--giveup:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(127, 29, 29, 0.85);
}

.btn--modal-primary {
  flex: 1;
  min-width: 8rem;
  background: #22c55e;
  color: #052e16;
  border: none;
  font-weight: 800;
  border-radius: 12px;
  transition:
    background 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
  box-shadow: 0 2px 0 #15803d;
}

.btn--modal-primary:hover:not(:disabled) {
  background: #16a34a;
  transform: scale(1.02);
}

.btn--modal-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn--modal-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 0 #15803d;
}

.btn--modal-secondary {
  flex: 1;
  min-width: 6rem;
  background: rgba(15, 23, 42, 0.55);
  color: var(--panel-text);
  border: 2px solid rgba(148, 163, 184, 0.4);
  font-weight: 700;
  border-radius: 12px;
}

.btn--modal-secondary:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(203, 213, 225, 0.45);
}

/* --- Modal saisie Pokémon (<dialog>) --- */
.poke-modal-dialog {
  border: none;
  padding: 0;
  margin: auto;
  max-width: calc(100vw - 1.5rem);
  background: transparent;
  overflow: visible;
}

.poke-modal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(26rem, calc(100vw - 1.5rem));
  padding: 1.5rem 1.35rem 1.4rem;
  border-radius: var(--radius);
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 28px 64px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 var(--panel-inset);
  overflow: visible;
}

.modal__title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--panel-text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.modal__lead {
  margin: 0 0 1rem;
  font-size: 0.92rem;
  color: var(--panel-text-soft);
  line-height: 1.45;
}

.modal__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1.15rem;
}

.modal__badge-slot .badge {
  min-height: 2.65rem;
  width: 100%;
  max-width: 14rem;
}

.modal__badge-join {
  align-self: center;
  font-weight: 900;
  font-size: 1.1rem;
  color: #a5b4fc;
  opacity: 0.95;
  text-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
}

.modal__field-label {
  display: block;
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--panel-muted);
}

.modal__field-wrap {
  position: relative;
}

.modal__input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  color: var(--panel-text);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.modal__input::placeholder {
  color: rgba(148, 163, 184, 0.75);
}

.modal__input:hover {
  border-color: rgba(203, 213, 225, 0.45);
  background: rgba(15, 23, 42, 0.82);
}

.modal__input:focus {
  outline: none;
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
  background: rgba(15, 23, 42, 0.88);
}

.modal__error {
  margin: 0.65rem 0 0;
  padding: 0.55rem 0.65rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #991b1b;
  background: var(--red-soft);
  border: 1px solid #fecaca;
  border-radius: 10px;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

/* --- Victory --- */
.victory {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.victory[hidden] {
  display: none !important;
}

.victory__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.victory--show .victory__backdrop {
  opacity: 1;
}

.victory__card {
  position: relative;
  max-width: 22rem;
  width: 100%;
  padding: 2rem 1.5rem 1.75rem;
  text-align: center;
  background: linear-gradient(160deg, #fff 0%, #fef9c3 100%);
  border-radius: var(--radius);
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(251, 191, 36, 0.5);
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  transition:
    transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.4s ease;
}

.victory--show .victory__card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.victory__confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.victory__confetti span {
  position: absolute;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 2.4s ease-out forwards;
}

.victory--show .victory__confetti span:nth-child(1) {
  left: 8%;
  background: #f59e0b;
  animation-delay: 0.05s;
}
.victory--show .victory__confetti span:nth-child(2) {
  left: 18%;
  background: #22c55e;
  animation-delay: 0.12s;
}
.victory--show .victory__confetti span:nth-child(3) {
  left: 28%;
  background: #3b82f6;
  animation-delay: 0.08s;
}
.victory--show .victory__confetti span:nth-child(4) {
  left: 42%;
  background: #ef4444;
  animation-delay: 0.18s;
}
.victory--show .victory__confetti span:nth-child(5) {
  left: 55%;
  background: #a855f7;
  animation-delay: 0.1s;
}
.victory--show .victory__confetti span:nth-child(6) {
  left: 68%;
  background: #f472b6;
  animation-delay: 0.15s;
}
.victory--show .victory__confetti span:nth-child(7) {
  left: 78%;
  background: #22d3ee;
  animation-delay: 0.2s;
}
.victory--show .victory__confetti span:nth-child(8) {
  left: 88%;
  background: #eab308;
  animation-delay: 0.06s;
}
.victory--show .victory__confetti span:nth-child(9) {
  left: 12%;
  background: #6366f1;
  animation-delay: 0.22s;
}
.victory--show .victory__confetti span:nth-child(10) {
  left: 50%;
  background: #f97316;
  animation-delay: 0.14s;
}
.victory--show .victory__confetti span:nth-child(11) {
  left: 32%;
  background: #14b8a6;
  animation-delay: 0.17s;
}
.victory--show .victory__confetti span:nth-child(12) {
  left: 92%;
  background: #ec4899;
  animation-delay: 0.09s;
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(-20px) rotate(0deg);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0.85;
    transform: translateY(140px) rotate(260deg);
  }
}

.victory__sparkles {
  position: absolute;
  inset: -30% -20%;
  background:
    radial-gradient(circle, rgba(251, 191, 36, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(34, 197, 94, 0.25) 0%, transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.2) 0%, transparent 35%);
  pointer-events: none;
  animation: sparkle 2.5s ease-in-out infinite;
  z-index: -1;
}

.victory:not(.victory--static) .victory__sparkles {
  animation: sparkle 2.5s ease-in-out infinite;
}

@keyframes sparkle {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.08) rotate(4deg);
  }
}

.victory__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.victory__sub {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.victory__btn {
  margin-top: 1.25rem;
}

.victory--static .victory__card {
  transition: none;
  transform: scale(1);
  opacity: 1;
}

.victory--static .victory__backdrop {
  opacity: 1;
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .cell--shake,
  .cell--pop,
  .cell--glow,
  .cell--error-flash,
  .spinner,
  .victory__confetti span,
  .victory__sparkles {
    animation: none !important;
  }

  .theme-tag--lit,
  .cell:not(:disabled):not(.cell--success):hover {
    transform: none;
  }

  .victory__card {
    transition: opacity 0.2s ease !important;
  }
}
