/* ─── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ─── Scrollbar ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 3px; }

/* ─── Cookie popup ────────────────────────────────────────────────────── */
.cookie-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.cookie-popup {
  background: #1a1a2e;
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.cookie-popup-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.cookie-popup-close:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.cookie-icon { font-size: 48px; margin-bottom: 8px; }
.cookie-popup h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  margin-bottom: 8px;
  color: #FFD700;
}
.cookie-sub { font-size: 14px; color: #ccc; margin-bottom: 16px; }
.cookie-features {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px; font-size: 13px; text-align: left;
  padding: 12px; background: rgba(255,255,255,0.05); border-radius: 12px;
}
.cookie-warning { font-size: 12px; color: #f0ad4e; margin-bottom: 12px; }
.cookie-tip { font-size: 13px; margin-bottom: 8px; }
.cookie-links {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 16px;
  flex-wrap: wrap;
}
.cookie-links a {
  display: inline-block;
  padding: 6px 16px;
  background: #FF6B35;
  color: #fff;
  border-radius: 20px;
  font-size: 13px; font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s;
}
.cookie-links a:hover { transform: scale(1.05); }
.cookie-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.cookie-delete {
  padding: 10px 18px;
  background: transparent;
  color: #ff6b6b;
  border: 2px solid #ff6b6b;
  border-radius: 12px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.cookie-delete:hover { background: rgba(255,107,107,0.15); }
.cookie-accept {
  padding: 10px 28px;
  background: #4ECDC4;
  color: #1a1a2e;
  border: none;
  border-radius: 12px;
  font-size: 16px; font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s;
}
.cookie-accept:hover { transform: scale(1.05); }

.cookie-btn {
  position: fixed; bottom: 16px; right: 16px; z-index: 999;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: #FF6B35;
  border: 3px solid #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: transform 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.cookie-btn:hover { transform: scale(1.1); }

/* ─── Header ──────────────────────────────────────────────────────────── */
.header {
  padding: 12px 16px;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}
.header-back {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 16px; font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.header-back:hover { background: rgba(255,255,255,0.25); }
.header-title {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: #FFD700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

/* ─── Home ────────────────────────────────────────────────────────────── */
.home {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
@media (min-width: 600px) {
  .home-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
}
@media (min-width: 900px) {
  .home-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
}

.home-card {
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  border: 3px solid transparent;
}
.home-card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }
.home-card:active { transform: scale(0.97); }

.home-card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: rgba(255,255,255,0.05);
}
.home-card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: rgba(255,255,255,0.05);
}

.home-card-name {
  padding: 10px 12px;
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Series view ─────────────────────────────────────────────────────── */
.series-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}
.series-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.series-emoji { font-size: 36px; }
.series-name {
  font-family: 'Fredoka One', cursive;
  font-size: 28px;
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
@media (min-width: 600px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
}
@media (min-width: 900px) {
  .video-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px; }
}

.video-card {
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border: 2px solid transparent;
}
.video-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.25); }
.video-card:active { transform: scale(0.96); }

.video-card-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.video-card-title {
  padding: 8px 10px;
  font-size: 13px; font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── Player overlay ──────────────────────────────────────────────────── */
.player-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: #000;
  display: none;
  flex-direction: column;
}
.player-overlay.open { display: flex; }

/* Plein écran natif */
.player-overlay:fullscreen,
.player-overlay:-webkit-full-screen {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.player-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.player-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.player-close-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  font-size: 22px; font-weight: 800;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 0.2s, transform 0.2s;
}
.player-close-btn:hover { background: rgba(255,255,255,0.35); transform: scale(1.1); }
.player-title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: rgba(255,255,255,0.9);
}

.player-video-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
#player-video {
  position: absolute;
  inset: 0;
}
.player-video-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.player-tap-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 20px;
  pointer-events: none;
  animation: pulseHint 2s ease-in-out infinite;
}
@keyframes pulseHint {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

.player-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  padding: 60px 14px 14px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.player-bottom.visible {
  opacity: 1;
  pointer-events: auto;
}

.carousel-header {
  font-size: 14px; font-weight: 700;
  color: #FFD700;
  margin-bottom: 8px;
}
.carousel-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.carousel-track::-webkit-scrollbar { height: 4px; }
.carousel-track::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 2px; }

.carousel-item {
  flex: 0 0 160px;
  scroll-snap-align: start;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  transition: transform 0.15s;
  border: 2px solid transparent;
}
.carousel-item:hover { transform: scale(1.05); }
.carousel-item.active { border-color: #FFD700; }
.carousel-item img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}
.carousel-item-title {
  font-size: 11px;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0,0,0,0.5);
}

/* ─── Loader ──────────────────────────────────────────────────────────── */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}
.spinner {
  width: 40px; height: 40px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #FFD700;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-box {
  text-align: center;
  padding: 40px 20px;
}
.error-box .error-icon { font-size: 48px; margin-bottom: 12px; }
.error-box p { color: rgba(255,255,255,0.7); margin-bottom: 16px; }
.error-box button {
  padding: 10px 24px;
  border: none;
  border-radius: 12px;
  background: #4ECDC4;
  color: #1a1a2e;
  font-weight: 700;
  cursor: pointer;
}
