/* ===== Reset ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* ===== Variables de thème ===== */
:root {
  --bg-page: #f0f0f5;
  --bg-card: #ffffff;
  --bg-secondary: #e8e8f0;
  --bg-glass: rgba(255,255,255,0.7);
  --text-primary: #1a1a2e;
  --text-heading: #0f0f1a;
  --text-muted: #6b6b80;
  --border-color: #e0e0ea;
  --header-bg: #0f0f1a;
  --header-input-bg: #252540;
  --accent: #7c3aed;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124,58,237,0.25);
  --card-radius: 12px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
}

html[data-theme="dark"] {
  --bg-page: #0d0d1a;
  --bg-card: #16162a;
  --bg-secondary: #1e1e35;
  --bg-glass: rgba(22,22,42,0.8);
  --text-primary: #e8e8f5;
  --text-heading: #f5f5ff;
  --text-muted: #8888aa;
  --border-color: #2a2a45;
  --header-bg: #080810;
  --header-input-bg: #1e1e35;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}

/* ===== Base ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.4;
  overflow-x: hidden;
  transition: background 0.25s, color 0.25s;
}
img { max-width: 100%; }
a { text-decoration: none; color: inherit; }

/* ===== Header ===== */
.site-header {
  background: var(--header-bg);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

/* Ligne décorative violette en bas du header */
.site-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-light), transparent);
}

.logo a {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  letter-spacing: -0.3px;
}
.logo span {
  color: var(--accent-light);
  text-shadow: 0 0 20px var(--accent-glow);
}

/* Hover animé sur le logo */
.logo a:hover .logo span { animation: pulse-glow 0.6s ease; }
@keyframes pulse-glow {
  0% { text-shadow: 0 0 20px var(--accent-glow); }
  50% { text-shadow: 0 0 40px rgba(124,58,237,0.6); }
  100% { text-shadow: 0 0 20px var(--accent-glow); }
}

.main-nav {
  display: flex;
  gap: 0.6rem;
  flex: 1 1 auto;
  flex-wrap: wrap;
}
.main-nav a {
  color: #ccc;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s;
}
.main-nav a:hover { color: var(--accent-light); }

/* ===== Menu déroulant genres ===== */
.genre-dropdown { position: relative; }
.genre-toggle {
  background: var(--header-input-bg);
  color: #fff;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.genre-toggle:hover {
  background: rgba(124,58,237,0.2);
  border-color: var(--accent-light);
}
.genre-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-color);
  padding: 8px;
  min-width: 210px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 9999;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.genre-menu.open { display: grid; }
.genre-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  font-size: 0.84rem;
  color: var(--text-primary);
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.1s;
}
.genre-menu a:hover { background: var(--bg-secondary); color: var(--accent); }
.genre-count {
  background: rgba(124,58,237,0.12);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
  float: none;
}

/* ===== Boutons header ===== */
.random-btn, .theme-toggle {
  background: var(--header-input-bg);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.random-btn:hover, .theme-toggle:hover {
  background: rgba(124,58,237,0.2);
  border-color: var(--accent-light);
}
.theme-toggle { padding: 7px 10px; line-height: 1; }

/* ===== Barre de recherche ===== */
.search-bar {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 280px;
  position: relative;
}
.search-bar input {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 8px 16px 8px 36px;
  font-size: 0.85rem;
  width: 100%;
  background: var(--header-input-bg);
  color: #fff;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.search-bar input:focus {
  border-color: var(--accent-light);
  background-color: rgba(124,58,237,0.1);
}
.search-bar input::placeholder { color: #777; }

/* Dropdown suggestions */
.search-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-color);
  z-index: 9999;
  overflow: hidden;
  max-height: 340px;
  overflow-y: auto;
}
.search-suggestions.open { display: block; }
.search-suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: var(--text-primary);
}
.search-suggestion-item:hover { background: var(--bg-secondary); }
.search-suggestion-item img {
  width: 38px; height: 38px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.search-suggestion-item .suggestion-emoji {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  flex-shrink: 0;
}
.search-suggestion-info .suggestion-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text-heading);
}
.search-suggestion-info .suggestion-cat {
  font-size: 0.72rem; color: var(--text-muted);
}
.search-suggestion-none {
  padding: 14px; text-align: center;
  font-size: 0.82rem; color: var(--text-muted);
}
.search-suggestion-item.focused,
.search-suggestion-item:focus {
  background: var(--bg-secondary);
  outline: none;
}

/* ===== Hero section ===== */
.hero-section {
  background: linear-gradient(180deg,
    var(--header-bg) 0%,
    #1a0a2e 40%,
    var(--bg-page) 100%
  );
  padding: 2.5rem 1.5rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 20% 50%, rgba(124,58,237,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 60% at 80% 50%, rgba(56,189,248,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.hero-section h1 {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 0.6rem;
  position: relative;
}
.hero-section h1 span { color: var(--accent-light); }
.hero-section p {
  font-size: 1rem;
  color: rgba(255,255,255,0.55);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ===== Pubs ===== */
.ad-banner {
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 1rem auto;
  width: 100%;
  overflow: hidden;
  position: relative;
  border-radius: 8px;
}
.ad-banner ins.adsbygoogle { max-width: 100%; max-height: 100%; }
.ad-728x90 { max-width: 728px; aspect-ratio: 728/90; min-height: 50px; }
.ad-160x600 { width: 160px; min-height: 600px; flex-shrink: 0; }
@media (max-width: 1100px) {
  .ad-160x600 {
    width: 100%; max-width: 468px;
    min-height: 60px; aspect-ratio: 468/60;
  }
}

/* ===== Sections de jeux ===== */
.games-section {
  padding: 1.5rem;
  max-width: 1280px;
  margin: 0 auto;
}
.games-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== Grille ===== */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: 160px;
  grid-auto-flow: dense;
  gap: 0.85rem;
}
.games-grid .game-card { height: 100%; }
.games-grid .game-card a { position: relative; height: 100%; }
.games-grid .game-card img,
.games-grid .game-card .card-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  aspect-ratio: auto !important;
}
.games-grid .game-card .game-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1.2rem 0.75rem 0.6rem;
  background: linear-gradient(to top, rgba(0,0,0,0.82), rgba(0,0,0,0));
}
.games-grid .game-card .game-info h3 {
  color: #fff !important; font-size: 0.84rem !important;
  font-weight: 600 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.games-grid .game-card .game-info span {
  color: rgba(255,255,255,0.75) !important; font-size: 0.7rem !important;
}

/* Grande tuile */
.games-grid .game-card.featured-big { grid-column: span 2; grid-row: span 2; }
.games-grid .game-card.featured-big .game-info h3 { font-size: 1.05rem !important; }
.games-grid .game-card.featured-big .game-info span { font-size: 0.8rem !important; }

@media (max-width: 480px) {
  .games-section { padding: 1rem; }
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-auto-rows: 120px; gap: 0.65rem;
  }
}

/* ===== Layout "À la une" ===== */
.featured-layout {
  display: flex; gap: 1rem;
  align-items: flex-start; margin: 1.5rem;
}
.featured-side-ad {
  flex-shrink: 0; width: 300px; min-height: 600px;
  max-width: 300px; overflow: hidden;
}
.featured-side-ad ins { max-width: 300px !important; max-height: 600px !important; }
@media (max-width: 1100px) { .featured-side-ad { display: none; } }

.featured-grid {
  flex: 1; display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 160px; grid-auto-flow: dense; gap: 0.85rem;
}
.featured-grid .game-card { height: 100%; }
.featured-grid .game-card a { position: relative; height: 100%; }
.featured-grid .game-card img,
.featured-grid .game-card .card-thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%; aspect-ratio: auto !important;
}
.featured-grid .game-card .game-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 1.2rem 0.75rem 0.6rem;
  background: linear-gradient(to top, rgba(0,0,0,0.82), rgba(0,0,0,0));
}
.featured-grid .game-card .game-info h3 {
  color: #fff !important; font-size: 0.84rem !important;
}
.featured-grid .game-card .game-info span {
  color: rgba(255,255,255,0.75) !important;
}
.featured-grid .game-card.featured-big { grid-column: span 2; grid-row: span 2; }
.featured-grid .game-card.featured-big .game-info h3 { font-size: 1.05rem !important; }
.featured-grid .game-card.featured-big .game-info span { font-size: 0.82rem !important; }

@media (max-width: 700px) {
  .featured-grid {
    grid-template-columns: repeat(2, 1fr); grid-auto-rows: 130px;
  }
  .featured-grid .game-card.featured-big { grid-column: span 2; grid-row: span 2; }
}

/* ===== Cartes ===== */
.game-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--card-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
  display: block;
  animation: card-appear 0.4s ease both;
}
@keyframes card-appear {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-md), 0 0 0 2px rgba(124,58,237,0.2);
}

/* Effet de brillance au hover sur l'image */
.game-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 1;
}
.game-card:hover::after { opacity: 1; }

.game-card img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover; display: block;
  background: var(--bg-secondary);
  transition: transform 0.3s ease;
}
.game-card:hover img { transform: scale(1.05); }

.game-card .game-info { padding: 0.55rem 0.65rem 0.6rem; }
.game-card .game-info h3 {
  font-size: 0.84rem; font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-card .game-info span { font-size: 0.7rem; color: var(--text-muted); }

/* Placeholder coloré par catégorie (quand pas d'image) */
.card-thumb {
  width: 100%; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
  position: relative; overflow: hidden;
}
.card-thumb::before {
  content: '';
  position: absolute; inset: 0;
  background: inherit;
  filter: blur(20px);
  opacity: 0.5;
}

/* Bouton favori */
.fav-btn {
  position: absolute; top: 7px; right: 7px;
  width: 30px; height: 30px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  font-size: 0.95rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7);
  z-index: 3;
  transition: background 0.15s, transform 0.15s;
}
.fav-btn:hover { background: rgba(0,0,0,0.65); transform: scale(1.15); }
.fav-btn.active { color: #ff4d6d; background: rgba(0,0,0,0.6); }

/* Badge "Nouveau" */
.new-badge {
  position: absolute; top: 7px; left: 7px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff; font-size: 0.62rem; font-weight: 700;
  padding: 3px 9px; border-radius: 10px; z-index: 3;
  box-shadow: 0 2px 8px rgba(124,58,237,0.4);
  letter-spacing: 0.3px;
}

/* Étoiles sur les cartes */
.card-stars {
  color: #fbbf24; font-size: 0.72rem;
  margin-top: 3px; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 2px;
}
.card-stars-count { color: var(--text-muted); font-size: 0.65rem; }

/* Section "À la une" */
.featured-section {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.3rem 1.3rem 1.6rem;
  flex: 1; min-width: 0;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}
.featured-section h2 { color: var(--text-heading); }

/* ===== Skeleton loader ===== */
.skeleton-card { border-radius: var(--card-radius); overflow: hidden; background: var(--bg-secondary); }
.skeleton-thumb {
  width: 100%; aspect-ratio: 1;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
}
.skeleton-text {
  height: 10px; margin: 8px 8px 6px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-card) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
}
@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Bouton retour en haut ===== */
#back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-glow);
  display: none; z-index: 10;
  transition: transform 0.2s, box-shadow 0.2s;
}
#back-to-top.visible { display: flex; align-items: center; justify-content: center; }
#back-to-top:hover { transform: translateY(-2px); box-shadow: 0 6px 24px var(--accent-glow); }

/* ===== Bouton "Voir plus" ===== */
.voir-plus-btn {
  display: block; margin: 2rem auto 0;
  background: transparent;
  color: var(--accent);
  border: 2px solid rgba(124,58,237,0.3);
  padding: 11px 36px; border-radius: 30px;
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}
.voir-plus-btn:hover {
  background: rgba(124,58,237,0.1);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* ===== Footer ===== */
.site-footer {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--text-muted); font-size: 0.8rem;
  border-top: 1px solid var(--border-color);
  margin-top: 2rem;
}
.site-footer a {
  color: var(--text-muted); text-decoration: underline;
  margin-top: 4px; display: inline-block;
  transition: color 0.15s;
}
.site-footer a:hover { color: var(--accent-light); }

/* ===== Layout page jeu ===== */
.game-layout {
  display: flex; justify-content: center;
  align-items: flex-start; gap: 1rem;
  padding: 1.5rem; flex-wrap: wrap;
}
.game-container { text-align: center; max-width: 100%; }
.game-container h1 {
  margin-bottom: 0.8rem;
  color: var(--text-heading);
  font-size: 1.4rem; font-weight: 800;
}

/* ===== iframe jeu ===== */
.iframe-wrap {
  position: relative; max-width: 100%; margin: 0 auto;
  border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-color);
}
.iframe-wrap.fake-fullscreen {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  max-width: 100vw; z-index: 9999;
  background: #000; margin: 0;
  border-radius: 0;
}
.iframe-wrap.fake-fullscreen #game-frame {
  width: 100%; height: 100%; max-width: 100%; aspect-ratio: auto;
}
body.fake-fullscreen-active { overflow: hidden; }

.exit-fake-fullscreen-btn {
  display: none; position: absolute;
  top: 12px; right: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff;
  border: none; font-size: 1.1rem; cursor: pointer; z-index: 10000;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
.iframe-wrap.fake-fullscreen .exit-fake-fullscreen-btn {
  display: flex; align-items: center; justify-content: center;
}
.exit-fake-fullscreen-btn:hover { background: rgba(124,58,237,0.7); }

/* ===== Bouton thème ===== */
@media (max-width: 600px) {
  .game-layout { padding: 0.8rem; gap: 0.6rem; }
  .game-container h1 { font-size: 1.1rem; }
}

/* ===== Couleurs de placeholder par catégorie ===== */
.cat-action    .card-thumb { background: linear-gradient(135deg, #3d0000, #7c1010); }
.cat-puzzle    .card-thumb { background: linear-gradient(135deg, #001a3d, #10407c); }
.cat-course    .card-thumb { background: linear-gradient(135deg, #1a2000, #3d5c00); }
.cat-sport     .card-thumb { background: linear-gradient(135deg, #002a10, #006630); }
.cat-aventure  .card-thumb { background: linear-gradient(135deg, #2a1500, #6b3800); }
.cat-football  .card-thumb { background: linear-gradient(135deg, #002a10, #005c25); }
.cat-battle    .card-thumb { background: linear-gradient(135deg, #1a001a, #4a0050); }
.cat-puzzle    .card-thumb { background: linear-gradient(135deg, #001040, #003080); }

