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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  padding-top: 5px;
}

/* ── Ambient background ── */
.ambient {
  display: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.5;
  animation: drift 20s ease-in-out infinite alternate;
}

.orb-a {
  width: 500px; height: 500px;
  background: var(--fr-blue);
  top: -10%; left: -5%;
  opacity: 0.22;
}

.orb-b {
  width: 400px; height: 400px;
  background: var(--fr-red);
  bottom: -5%; right: -5%;
  opacity: 0.18;
  animation-delay: -7s;
}

.orb-c {
  width: 300px; height: 300px;
  background: var(--fr-white);
  top: 40%; left: 50%;
  opacity: 0.06;
  animation-delay: -14s;
}

@keyframes drift {
  to { transform: translate(40px, 30px) scale(1.08); }
}

/* ── App shell ── */
.app {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ── Hero ── */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.hero h1 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tagline {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
}

.hero-pitch {
  flex: 1;
  min-width: min(100%, 320px);
  max-width: 420px;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--muted);
}

.hero-pitch strong {
  color: var(--text);
  font-weight: 600;
}

.hero-pitch a {
  color: var(--fr-red);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(237, 41, 57, 0.35);
}

.hero-pitch a:hover {
  border-bottom-color: var(--accent);
}

.hero-stats {
  display: none;
}

/* ── Mode switch ── */
.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.mode {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode svg { width: 18px; height: 18px; flex-shrink: 0; }

.mode:hover { color: var(--text); background: rgba(0, 35, 149, 0.15); }

.mode.active {
  background: linear-gradient(135deg, var(--fr-blue), #1a4fd6);
  color: #fff;
  box-shadow: 0 4px 20px var(--indigo-glow);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* ── Search ── */
.search-bar {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search::placeholder { color: var(--muted); }

#search:focus {
  border-color: rgba(0, 35, 149, 0.55);
  box-shadow: 0 0 0 4px var(--indigo-glow);
}

.search-hint {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font);
  font-size: 0.7rem;
  pointer-events: none;
}

@media (max-width: 600px) { .search-hint { display: none; } }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.25rem;
  align-items: start;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.eu-badge {
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 35, 149, 0.08);
  color: var(--fr-blue);
  border: 1px solid rgba(0, 35, 149, 0.15);
}

.cat-filter {
  margin: 0 0.75rem 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.8rem;
  outline: none;
}

.cat-filter:focus { border-color: rgba(0, 35, 149, 0.55); }

.category-scroll {
  overflow-y: auto;
  flex: 1;
  padding: 0.25rem 0.5rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 35, 149, 0.15) transparent;
}

.category-scroll::-webkit-scrollbar { width: 4px; }
.category-scroll::-webkit-scrollbar-thumb { background: rgba(0, 35, 149, 0.15); border-radius: 4px; }

.cat-divider {
  padding: 0.6rem 0.75rem 0.3rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--indigo);
}

.cat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 2px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.cat-btn:hover { background: var(--glass-hover); }

.cat-btn.active {
  background: rgba(0, 35, 149, 0.08);
  color: var(--fr-blue);
  font-weight: 600;
  border-left: 2px solid var(--fr-red);
}

.cat-btn.europe { border-left: 2px solid var(--indigo); padding-left: calc(0.75rem - 2px); }

.cat-btn .cat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-btn .cat-count {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--surface);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.cat-btn.active .cat-count { background: rgba(237, 41, 57, 0.12); color: var(--fr-red); }

/* ── Stage ── */
.stage { min-width: 0; }

.stage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.stage-head h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results-count {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
}

.card {
  position: relative;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: default;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 35, 149, 0.3);
  box-shadow: 0 8px 24px rgba(0, 35, 149, 0.1), 0 0 0 1px rgba(237, 41, 57, 0.08);
}

.card-visual {
  aspect-ratio: 16/10;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.card-visual.portrait { aspect-ratio: 2/3; }

.card-visual canvas,
.card-visual img,
.card-visual .img-slot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-drag: none;
}

.card-visual.contain canvas,
.card-visual.contain img,
.card-visual.contain .img-slot { object-fit: contain; }

.card-visual.contain .img-slot img { object-fit: contain; padding: 0.75rem; }
.card-visual .img-slot { display: flex; align-items: center; justify-content: center; }
.card-visual .img-slot img { width: 100%; height: 100%; object-fit: cover; }

.shimmer {
  animation: shimmer 1.2s ease-in-out infinite alternate;
}

@keyframes shimmer {
  from { opacity: 0.45; }
  to { opacity: 0.9; }
}

.load-more {
  grid-column: 1 / -1;
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.card-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  pointer-events: none;
}

.card-visual .ph {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-glow), var(--indigo-glow));
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.card-play {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.4);
  opacity: 1;
  transition: background 0.2s;
  pointer-events: auto;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card:hover .card-play {
  background: rgba(0,0,0,0.55);
}

.card-play .play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--fr-red);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 20px var(--accent-glow);
  border: 2px solid var(--fr-white);
  transition: transform 0.15s, background 0.15s;
}

.card-play:hover .play-btn {
  background: var(--fr-blue);
  box-shadow: 0 4px 20px var(--indigo-glow);
}

.card-play:hover .play-btn,
.card-play:active .play-btn { transform: scale(1.08); }
.card-play svg { width: 22px; height: 22px; margin-left: 2px; pointer-events: none; }

.card-body { padding: 0.65rem 0.75rem 0.75rem; }

.card-title {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-rating {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  font-size: 0.7rem;
  font-weight: 600;
  color: #fbbf24;
}

/* ── States ── */
.state-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  color: var(--muted);
  text-align: center;
}

.state-msg svg { width: 48px; height: 48px; opacity: 0.4; }
.state-msg small { font-size: 0.8rem; opacity: 0.7; }

.pulse-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

.sidebar-close {
  display: none;
  border: none;
  background: var(--surface);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-cat-toggle {
  display: none;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  margin-bottom: 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  position: sticky;
  top: 0.35rem;
  z-index: 30;
}

.cat-hint {
  display: none;
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.mobile-cat-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--fr-blue);
}

.mobile-cat-toggle .chevron {
  margin-left: auto;
  color: var(--muted);
}

.mobile-cat-toggle span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

body.drawer-open {
  overflow: hidden;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .mobile-cat-toggle {
    display: flex;
  }

  .cat-hint {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: min(88vh, 720px);
    max-height: none;
    z-index: 1001;
    border-radius: 20px 20px 0 0;
    transform: translateY(110%);
    transition: transform 0.28s ease;
    overflow: hidden;
    margin: 0;
    box-shadow: 0 -8px 32px rgba(0, 35, 149, 0.12);
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateY(0);
    pointer-events: auto;
  }

  .cat-btn {
    padding: 0.9rem 0.85rem;
    font-size: 0.95rem;
    min-height: 48px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 35, 149, 0.25);
  }

  .category-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    pointer-events: auto;
  }

  .sidebar-close {
    display: grid;
    place-items: center;
  }

  .sidebar-head {
    padding: 1.1rem 1rem 0.65rem;
    font-size: 0.95rem;
  }

  .cat-filter {
    font-size: 16px;
    padding: 0.75rem 0.85rem;
  }

  .category-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  }

  .cat-btn {
    padding: 0.9rem 0.85rem;
    font-size: 0.95rem;
    min-height: 48px;
  }

  .hero-pitch {
    max-width: none;
    font-size: 0.85rem;
  }

  .hero {
    margin-bottom: 1rem;
  }

  .card-play {
    opacity: 1;
    background: linear-gradient(to top, rgba(0,0,0,0.65), transparent 55%);
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0.5rem;
  }

  .card-play .play-btn {
    width: 42px;
    height: 42px;
  }

  .card:hover {
    transform: none;
  }

  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
  }

  .card-body {
    padding: 0.45rem 0.4rem 0.55rem;
  }

  .card-title {
    font-size: 0.72rem;
  }

  .card-play .play-btn {
    width: 36px;
    height: 36px;
  }

  .card-play svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 480px) {
  .app { padding: 0.85rem 0.75rem 2.5rem; }
  .mode { font-size: 0.82rem; padding: 0.7rem 0.45rem; }
  .mode svg { display: none; }
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
  }
  .card-body { padding: 0.4rem 0.35rem 0.5rem; }
  .card-title { font-size: 0.68rem; }
  .stage-head h2 { font-size: 1rem; }
  #search { font-size: 16px; }
}
