:root {
  --bg: #0f172a;
  --surface: #111827;
  --card: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --primary: #60a5fa;
  --accent: #34d399;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 25px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, #0b1220, var(--bg));
  color: var(--text);
  font-family: "Source Sans 3", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.app-header {
  padding: 48px 0 28px;
  background: radial-gradient(1200px 200px at 50% -80px, rgba(96,165,250,0.18), transparent), transparent;
  text-align: center;
}
.app-header h1 {
  margin: 0 0 12px;
  font-family: Raleway, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 700;
  font-size: 3.5rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, var(--primary), var(--accent), var(--primary));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 3s ease infinite;
  text-shadow: 0 0 30px rgba(96, 165, 250, 0.3);
}
@media (min-width: 640px) {
  .app-header h1 {
    font-size: 4.5rem;
  }
}
@media (min-width: 960px) {
  .app-header h1 {
    font-size: 5.5rem;
  }
}
.subtitle {
  margin: 0;
  color: var(--muted);
  font-family: Roboto, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
}
@keyframes gradientShift {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.controls {
  margin: 20px 0 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px) {
  .controls { grid-template-columns: 1fr 1fr auto; align-items: end; }
}

.control label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
}
.control select {
  width: 100%;
  padding: 10px 12px;
  background: #f9fafb;
  color: #020617;
  border: 1px solid #253045;
  border-radius: 12px;
  outline: none;
  transition: border .2s ease, box-shadow .2s ease, background .2s ease;
}
.control select:hover { background: #e5e7eb; }
.control select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.22);
}
.control select option {
  color: #020617;
  background: #ffffff;
}

.count {
  padding: 10px 12px;
  background: linear-gradient(180deg, #0e1526, #0b1220);
  border: 1px solid #253045;
  border-radius: 12px;
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(96,165,250,0.0);} 50%{ box-shadow: 0 0 0 8px rgba(96,165,250,0.12);} }

.status {
  min-height: 22px;
  color: var(--muted);
  margin-bottom: 10px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .cards-grid { grid-template-columns: 1fr; }
}

.card {
  position: relative;
  background: linear-gradient(180deg, #151c2c, var(--card));
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.28);
  transform: translateY(6px);
  opacity: 0;
  animation: cardIn .6s ease forwards;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.card:hover,
.card:focus-within,
.card.card--hovered {
  transform: translateY(-4px) scale(1.04);
  box-shadow: 0 24px 52px rgba(0,0,0,0.42);
  border-color: rgba(255,255,255,0.12);
}
@keyframes cardIn { to { transform: translateY(0); opacity: 1; } }

.card__media {
  position: relative;
  height: 240px;
  overflow: hidden;
}
.card__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0e1526;
  transition: transform .35s ease, filter .35s ease;
  filter: saturate(1.05) contrast(1.02);
}
.card__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  border: none;
  background: #000;
}
.card--switch .card__image { object-position: top; }
.card:hover .card__image { transform: scale(1.04); filter: saturate(1.12) contrast(1.05); }
.card--hovered .card__image {
  transform: scale(1.12);
  filter: saturate(1.15) contrast(1.07);
}
.card--show-media .card__video { opacity: 1; }
.card--show-media .card__image { opacity: 0; transform: scale(1.02); }

.card__body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}
.card__title {
  margin: 0 0 10px;
  font-family: Raleway, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.2px;
}
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.93rem;
}
.card__meta .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--text);
}
.chip--gen { border-color: rgba(96,165,250,0.4); }
.chip--console { border-color: var(--accent); }
.chip--legend { border-color: rgba(245,158,11,0.5); color: #ffd68a; }

.card__row { display: grid; grid-template-columns: 1fr; gap: 6px; margin: 0; min-width: 0; }
@media (min-width: 520px){ .card__row { grid-template-columns: 180px 1fr; align-items: center; } }
.card__label { color: var(--muted); font-size: 0.78rem; letter-spacing: .04em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.card__label i { color: var(--muted); opacity: 0.9; transition: color .25s ease, opacity .25s ease; }
.card__label i.fa-star:hover, .card__label i.fa-crown:hover, .card__row:hover i.fa-star, .card__row:hover i.fa-crown { color: #fbbf24; opacity: 1; }
.card__label i.fa-heart:hover, .card__row:hover i.fa-heart { color: #ff6b93; opacity: 1; }
.card__value {
  color: var(--text);
  font-size: 0.98rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  min-width: 0;
  max-width: 100%;
}

/* Système de notation par étoiles avec animations */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rating .stars-container {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0;
}
.rating .star {
  font-size: 1.1rem;
  color: #253045;
  transition: all 0.3s ease;
  opacity: 0;
  transform: scale(0) rotate(-180deg);
  animation: starAppear 0.5s ease forwards;
}
.rating .star--full {
  color: #fbbf24;
  filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.5));
}
.card:hover .rating .star--full {
  animation: starShine 1.5s ease-in-out infinite;
}
.rating .star--half {
  color: #fbbf24;
  filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.5));
}
.rating .star--empty {
  color: #253045;
  opacity: 0.4;
}
.rating__value {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}
@keyframes starAppear {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  60% {
    transform: scale(1.2) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}
@keyframes starShine {
  0%, 100% {
    filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.5));
    transform: scale(1);
  }
  50% {
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.9));
    transform: scale(1.1);
  }
}
.rating--filling .star--full {
  animation: starFill 0.8s ease forwards;
}
@keyframes starFill {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.legend-icon {
  width: 16px; height: 16px; display: inline-block; color: #ffd68a;
}
.legend-icon svg { display: block; width: 100%; height: 100%; }

.app-footer { color: var(--muted); text-align: center; padding: 28px 0 40px; }

.evolution-badge {
  position: fixed;
  left: 24px;
  bottom: 24px;
  width: 140px;
  height: 140px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.evolution-badge img,
.evolution-badge video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: floatEgg 4s ease-in-out infinite;
}
.evolution-badge video {
  pointer-events: none;
}
@keyframes floatEgg {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Bouton de retour en haut */
.scroll-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  border-radius: 50%;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.8);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.scroll-to-top:hover {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  transform: translateY(0) scale(1.1);
  box-shadow: 0 6px 20px rgba(96, 165, 250, 0.4);
}

.scroll-to-top:active {
  transform: translateY(0) scale(0.95);
}

.scroll-to-top:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.22);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.scroll-to-top i {
  display: block;
}
