/* ============================================
   アニメ聖地マップ - Design System
   ============================================ */

/* === CSS Variables === */
:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(20, 20, 50, 0.85);
  --bg-glass: rgba(15, 15, 40, 0.75);
  --bg-hover: rgba(120, 80, 255, 0.12);

  --text-primary: #e8e6f0;
  --text-secondary: #9994b8;
  --text-muted: #6b6590;

  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-orange: #f97316;
  --accent-red: #ef4444;

  --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  --gradient-header: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(236, 72, 153, 0.1) 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.2) 0%, transparent 70%);

  --border-subtle: rgba(139, 92, 246, 0.15);
  --border-active: rgba(139, 92, 246, 0.4);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --sidebar-width: 360px;
  --header-height: 60px;

  --font-sans: 'Noto Sans JP', 'Inter', -apple-system, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* ============================================
   Header
   ============================================ */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
}

#app-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-header);
  pointer-events: none;
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.5));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.02em;
}

.header-stats {
  display: flex;
  gap: 8px;
}

.stat-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

/* Header Search (mobile only) */
.header-search {
  display: none;
  position: relative;
  align-items: center;
  flex: 1;
  min-width: 0;
  margin: 0 10px;
}

.header-search .search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

#header-search-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 36px 0 36px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

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

#header-search-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(255, 255, 255, 0.1);
}

#header-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

#header-search-clear {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  display: none;
  transition: var(--transition);
}

#header-search-clear.visible {
  display: block;
}

#header-search-clear:hover {
  color: var(--text-primary);
}

/* Sidebar Toggle */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 10;
}

.sidebar-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: var(--transition);
}

.sidebar-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.sidebar-toggle.active span:nth-child(2) {
  opacity: 0;
}
.sidebar-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  z-index: 900;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: var(--gradient-glow);
  pointer-events: none;
}

.sidebar-content {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Search */
.search-section {
  padding: 16px;
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: var(--transition);
}

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

#search-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.search-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  display: none;
  transition: var(--transition);
}

.search-clear:hover {
  color: var(--text-primary);
}

.search-clear.visible {
  display: block;
}

/* Promo Banner */
.promo-section {
  padding: 0 16px 14px;
  flex-shrink: 0;
}

.promo-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 132px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(90deg, rgba(6, 9, 24, 0.92) 0%, rgba(6, 9, 24, 0.78) 38%, rgba(6, 9, 24, 0.18) 100%),
    url("images/ad-seichi-map-banner.png") center / cover;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28), 0 0 24px rgba(6, 182, 212, 0.12);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.promo-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 42%);
  pointer-events: none;
}

.promo-banner:hover {
  transform: translateY(-1px);
  border-color: rgba(16, 185, 129, 0.42);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34), 0 0 28px rgba(6, 182, 212, 0.2);
}

.promo-banner:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 3px;
}

.promo-banner span {
  position: relative;
  z-index: 1;
}

.promo-eyebrow {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 182, 212, 0.18);
  color: #8ef8ff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.promo-title {
  max-width: 185px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.promo-copy {
  max-width: 170px;
  color: rgba(232, 230, 240, 0.82);
  font-size: 12px;
  line-height: 1.45;
}

.promo-cta {
  margin-top: 3px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.18);
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 700;
}

/* Filter Section */
.filter-section {
  padding: 0 16px 12px;
  flex-shrink: 0;
  min-height: 0;
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.filter-section-header:hover .section-title {
  color: var(--text-secondary);
}

.filter-toggle-icon {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform var(--transition);
  transform: rotate(0deg);
}

.filter-section.collapsed .filter-toggle-icon {
  transform: rotate(-90deg);
}

.filter-section-body {
  max-height: 130px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: max-height 0.3s ease;
}

.filter-section.collapsed .filter-section-body {
  max-height: 0;
  overflow: hidden;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0;
  transition: color var(--transition);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 4px;
}

.category-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.category-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
  color: var(--text-primary);
}

.category-chip.active {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* Anime List */
.anime-list-section {
  padding: 0 16px;
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.anime-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 20px;
}

.anime-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
}

.anime-list-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--gradient-primary);
  border-radius: 2px;
  transition: height var(--transition);
}

.anime-list-item:hover {
  background: var(--bg-hover);
}

.anime-list-item:hover::before {
  height: 60%;
}

.anime-list-item.active {
  background: rgba(139, 92, 246, 0.15);
}

.anime-list-item.active::before {
  height: 70%;
}

.anime-item-emoji {
  font-size: 22px;
  flex-shrink: 0;
}

.anime-item-info {
  flex: 1;
  min-width: 0;
}

.anime-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.anime-item-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   Map
   ============================================ */
#map-container {
  position: fixed;
  top: var(--header-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  z-index: 1;
  transition: left var(--transition);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
}

/* Leaflet Custom Styles */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  backdrop-filter: blur(10px) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-subtle) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
  font-size: 18px !important;
  transition: var(--transition) !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(139, 92, 246, 0.2) !important;
  border-color: var(--accent-purple) !important;
}

.leaflet-control-attribution {
  background: rgba(10, 10, 26, 0.7) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  backdrop-filter: blur(10px) !important;
}

.leaflet-control-attribution a {
  color: var(--accent-purple) !important;
}

/* Custom Markers */
.custom-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4), 0 0 20px var(--marker-glow, rgba(139, 92, 246, 0.3));
  transition: all 0.3s ease;
  cursor: pointer;
  animation: markerDrop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.custom-marker:hover {
  transform: rotate(-45deg) scale(1.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 30px var(--marker-glow, rgba(139, 92, 246, 0.5));
}

.custom-marker .marker-emoji {
  transform: rotate(45deg);
  font-size: 18px;
  line-height: 1;
}

@keyframes markerDrop {
  0% {
    opacity: 0;
    transform: rotate(-45deg) translateY(-30px) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: rotate(-45deg) translateY(0) scale(1);
  }
}

/* Marker Popup */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  backdrop-filter: blur(20px) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  font-family: var(--font-sans) !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: none !important;
}

.popup-content {
  padding: 16px;
  min-width: 220px;
}

.popup-anime-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  margin-bottom: 8px;
}

.popup-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.popup-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.popup-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--gradient-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.popup-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 20px !important;
  padding: 6px 8px !important;
}

.leaflet-popup-close-button:hover {
  color: var(--text-primary) !important;
}

/* ============================================
   Detail Panel
   ============================================ */
.detail-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 400px;
  max-height: calc(100vh - var(--header-height) - 20px);
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 1100;
  transform: translateY(110%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}

.detail-panel.open {
  transform: translateY(0);
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1201;
}

.detail-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-emoji {
  font-size: 48px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.4));
}

.detail-anime-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent-purple);
  margin-bottom: 6px;
}

.detail-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.detail-body {
  padding: 20px;
}

.detail-info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.detail-info-row svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent-purple);
  margin-top: 2px;
}

.detail-info-row span {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.detail-description {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  margin: 16px 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-purple);
}

.detail-actions {
  margin-top: 16px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.action-btn.primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

/* ============================================
   Comparison Image
   ============================================ */
.detail-image-container {
  margin-bottom: 16px;
}

.comparison-image {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

.comparison-image img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease;
}

.comparison-image:hover img {
  transform: scale(1.02);
}

.comparison-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0;
}

.comparison-label span {
  flex: 1;
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.label-anime {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.85), rgba(236, 72, 153, 0.85));
  color: #fff;
}

.label-real {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.85), rgba(6, 182, 212, 0.85));
  color: #fff;
}

/* ============================================
   Overlay
   ============================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 850;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }

  .header-stats {
    display: none;
  }

  .header-search {
    display: flex;
  }

  .header-inner {
    padding: 0 12px;
    gap: 8px;
  }

  .logo {
    flex-shrink: 0;
  }

  .logo h1 {
    display: none;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #map-container {
    left: 0;
  }

  .detail-panel {
    top: var(--header-height);
    bottom: 0;
    width: 100%;
    max-height: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
  }

  .detail-close {
    top: 12px;
    right: max(12px, env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 16px;
  }

  .logo-icon {
    font-size: 24px;
  }

  .sidebar {
    width: 100%;
  }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.anime-list-item {
  animation: slideUp 0.3s ease both;
}

.anime-list-item:nth-child(1) { animation-delay: 0.02s; }
.anime-list-item:nth-child(2) { animation-delay: 0.04s; }
.anime-list-item:nth-child(3) { animation-delay: 0.06s; }
.anime-list-item:nth-child(4) { animation-delay: 0.08s; }
.anime-list-item:nth-child(5) { animation-delay: 0.10s; }
.anime-list-item:nth-child(6) { animation-delay: 0.12s; }
.anime-list-item:nth-child(7) { animation-delay: 0.14s; }
.anime-list-item:nth-child(8) { animation-delay: 0.16s; }
.anime-list-item:nth-child(9) { animation-delay: 0.18s; }
.anime-list-item:nth-child(10) { animation-delay: 0.20s; }
.anime-list-item:nth-child(11) { animation-delay: 0.22s; }
.anime-list-item:nth-child(12) { animation-delay: 0.24s; }
.anime-list-item:nth-child(13) { animation-delay: 0.26s; }
.anime-list-item:nth-child(14) { animation-delay: 0.28s; }
.anime-list-item:nth-child(15) { animation-delay: 0.30s; }

/* Cluster Markers */
.custom-cluster {
  background: transparent !important;
}

.cluster-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 700;
  font-family: var(--font-sans);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.3);
  animation: clusterPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes clusterPop {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.cluster-icon span {
  font-size: 13px;
}

.cluster-small {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #8b5cf6, #a78bfa);
  font-size: 12px;
}

.cluster-medium {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  font-size: 13px;
}

.cluster-large {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #6d28d9, #7c3aed);
  font-size: 14px;
}

.cluster-xlarge {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #5b21b6, #ec4899);
  font-size: 15px;
}

/* Override default markercluster styles */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: transparent !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: transparent !important;
}

/* Anime list - more items indicator */
.anime-list-more {
  text-align: center;
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Section count badge */
.section-count {
  font-weight: 400;
  color: var(--accent-purple);
  font-size: 10px;
}

/* Map dark tiles adjustment */
.leaflet-tile-pane {
  filter: brightness(0.85) saturate(1.2);
  transition: filter 0.8s ease;
}

/* Anime map image overlays */
.anime-map-overlay {
  pointer-events: none !important;
  transition: opacity 0.6s ease;
  image-rendering: auto;
}

/* ============================================
   Anime Theme System
   ============================================ */

/* === Theme Overlay & Vignette === */
#theme-overlay {
  position: absolute;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#theme-overlay.active {
  opacity: 1;
}

#theme-vignette {
  position: absolute;
  inset: 0;
  z-index: 401;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

#theme-vignette.active {
  opacity: 1;
}

/* === Theme Grain/Paper Texture === */
#theme-grain {
  position: absolute;
  inset: 0;
  z-index: 402;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

#theme-grain.active {
  opacity: 0.35;
}

/* === Theme Logo === */
#theme-logo {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#theme-logo.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.theme-logo-text {
  display: inline-block;
  padding: 8px 24px;
  background: rgba(10, 0, 30, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--theme-accent, #818cf8);
  border-radius: var(--radius-xl);
  color: var(--theme-accent, #818cf8);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px var(--theme-accent, rgba(129, 140, 248, 0.6));
  box-shadow:
    0 0 30px rgba(129, 140, 248, 0.2),
    inset 0 0 20px rgba(129, 140, 248, 0.05);
  animation: themeLogoPulse 3s ease-in-out infinite;
}

@keyframes themeLogoPulse {
  0%, 100% {
    box-shadow:
      0 0 30px rgba(129, 140, 248, 0.2),
      inset 0 0 20px rgba(129, 140, 248, 0.05);
  }
  50% {
    box-shadow:
      0 0 50px rgba(129, 140, 248, 0.35),
      inset 0 0 30px rgba(129, 140, 248, 0.1);
  }
}

/* === Character Markers === */
.character-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.character-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  animation: characterBounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.character-marker-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 50%;
  border: 2px solid rgba(129, 140, 248, 0.6);
  background: rgba(10, 0, 30, 0.7);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(129, 140, 248, 0.3);
  transition: all 0.3s ease;
  animation: characterFloat 4s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

.character-marker:hover .character-marker-img {
  transform: scale(1.2);
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.6),
    0 0 35px rgba(129, 140, 248, 0.5);
  border-color: rgba(129, 140, 248, 0.9);
}

.character-marker-name {
  margin-top: 2px;
  padding: 2px 8px;
  background: rgba(10, 0, 30, 0.85);
  border: 1px solid rgba(129, 140, 248, 0.4);
  border-radius: 10px;
  font-size: 9px;
  font-weight: 600;
  color: rgba(129, 140, 248, 0.9);
  white-space: nowrap;
  text-shadow: 0 0 8px rgba(129, 140, 248, 0.4);
  position: relative;
  z-index: 2;
}

.character-marker-glow {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 8px;
  border-radius: 50%;
  opacity: 0.4;
  filter: blur(6px);
  z-index: 1;
}

@keyframes characterBounceIn {
  0% {
    opacity: 0;
    transform: translateY(-40px) scale(0.3);
  }
  60% {
    transform: translateY(5px) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes characterFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* === Cursed Energy Particles === */
#theme-particles {
  position: absolute;
  inset: 0;
  z-index: 399;
  pointer-events: none;
  overflow: hidden;
}

.theme-particle {
  position: absolute;
  width: var(--particle-size, 5px);
  height: var(--particle-size, 5px);
  background: var(--particle-color, #818cf8);
  border-radius: 50%;
  opacity: 0;
  filter: blur(1px);
  animation: particleFloat linear infinite;
  box-shadow: 0 0 8px var(--particle-color, #818cf8);
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0) scale(0.5);
  }
  15% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.4;
    transform: translateY(-80px) translateX(30px) scale(1);
  }
  85% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
    transform: translateY(-160px) translateX(-20px) scale(0.3);
  }
}

/* === Popup Episode === */
.popup-episode {
  font-size: 11px;
  color: var(--accent-purple);
  margin-bottom: 8px;
  font-weight: 500;
}

.popup-episode:empty {
  display: none;
}

/* === Popup Character Info === */
.popup-character {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(129, 140, 248, 0.15);
  color: #a5b4fc;
  margin-bottom: 6px;
}

/* === Themed Popup === */
.popup-content.themed {
  border-top: 2px solid rgba(129, 140, 248, 0.5);
}

.popup-content.themed .popup-anime-tag {
  background: rgba(129, 140, 248, 0.2);
  color: #a5b4fc;
}

/* === Body theme class adjustments === */
.anime-theme-active #app-header {
  border-bottom-color: rgba(129, 140, 248, 0.3);
}

.anime-theme-active #app-header::before {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(30, 0, 60, 0.15) 100%);
}

.anime-theme-active .stat-badge {
  background: rgba(129, 140, 248, 0.15);
  color: #a5b4fc;
  border-color: rgba(129, 140, 248, 0.3);
}

.anime-theme-active .sidebar {
  border-right-color: rgba(129, 140, 248, 0.2);
}

.anime-theme-active .sidebar::before {
  background: radial-gradient(circle at 50% 0%, rgba(129, 140, 248, 0.2) 0%, transparent 70%);
}

/* ============================================
   Character Markers (Anime Theme)
   ============================================ */
.character-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.character-marker {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: characterDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.character-marker:hover {
  transform: scale(1.15) translateY(-4px);
}

.character-marker-img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(129, 140, 248, 0.7);
  box-shadow:
    0 0 12px rgba(129, 140, 248, 0.5),
    0 0 24px rgba(129, 140, 248, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.5);
  background: var(--bg-primary);
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
}

.character-marker:hover .character-marker-img {
  border-color: rgba(129, 140, 248, 1);
  box-shadow:
    0 0 20px rgba(129, 140, 248, 0.7),
    0 0 40px rgba(129, 140, 248, 0.3),
    0 6px 16px rgba(0, 0, 0, 0.5);
}

.character-marker-name {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  color: #e8e6f0;
  background: rgba(15, 15, 40, 0.85);
  border: 1px solid rgba(129, 140, 248, 0.3);
  white-space: nowrap;
  text-align: center;
  backdrop-filter: blur(8px);
  z-index: 2;
  position: relative;
}

.character-marker-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  opacity: 0.25;
  filter: blur(12px);
  z-index: 1;
  animation: characterGlow 3s ease-in-out infinite alternate;
}

@keyframes characterDrop {
  0% {
    opacity: 0;
    transform: translateY(-40px) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes characterGlow {
  0% { opacity: 0.2; transform: translate(-50%, -60%) scale(0.9); }
  100% { opacity: 0.4; transform: translate(-50%, -60%) scale(1.1); }
}

/* Text-based character marker (no image) */
.character-marker-initial {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.4);
  position: relative;
  z-index: 2;
  transition: all 0.3s ease;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.character-marker:hover .character-marker-initial {
  border-color: rgba(255, 255, 255, 0.7);
  transform: scale(1.05);
}

.all-spots-character-marker .character-marker-name {
  display: none;
}

.all-spots-character-marker .character-marker-img {
  width: 44px;
  height: 44px;
  border-width: 2px;
}

.all-spots-character-marker .character-marker-initial {
  width: 42px;
  height: 42px;
  border-width: 2px;
  font-size: 16px;
}
