.factions-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 7rem 2rem 4rem;
  position: relative;
  z-index: 10;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Force scroll on mobile for factions page - apply globally */
html,
body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  height: 100%;
  min-height: 100vh;
  position: relative;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.page-header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-title {
  font-family: "Cinzel", serif;
  font-size: 3.5rem;
  background: linear-gradient(135deg, #4dd4ff, #ffd700, #ff6b9d, #4dd4ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 6s ease infinite;
  filter: drop-shadow(0 0 30px rgba(77, 212, 255, 0.5));
  letter-spacing: 3px;
  position: relative;
  display: inline-block;
  font-weight: 700;
}

.page-title::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120%;
  height: 120%;
  background: radial-gradient(
    circle,
    rgba(77, 212, 255, 0.1) 0%,
    transparent 70%
  );
  filter: blur(30px);
  z-index: -1;
  animation: titleGlow 3s ease-in-out infinite;
}

@keyframes titleGlow {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

@keyframes gradientShift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.page-subtitle {
  color: rgba(232, 240, 255, 0.9);
  max-width: 700px;
  margin: 1rem auto 0;
  font-size: 1.15rem;
  line-height: 1.7;
  animation: fadeIn 0.8s ease-out 0.3s both;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  font-weight: 500;
}

.factions-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 3rem;
  flex-wrap: wrap;
  align-items: center;
  animation: slideDown 0.5s ease-out 0.2s both;
}

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

.factions-controls input,
.factions-controls select {
  padding: 1rem 1.4rem;
  border-radius: 14px;
  border: 2px solid rgba(77, 212, 255, 0.4);
  background: rgba(21, 27, 61, 0.9);
  backdrop-filter: blur(15px);
  color: #e8f0ff;
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.factions-controls input::placeholder {
  color: rgba(232, 240, 255, 0.5);
  font-style: italic;
}

.factions-controls input:focus,
.factions-controls select:focus {
  outline: none;
  border-color: rgba(77, 212, 255, 1);
  box-shadow:
    0 0 30px rgba(77, 212, 255, 0.6),
    0 6px 25px rgba(0, 0, 0, 0.4);
  transform: translateY(-3px) scale(1.02);
}

.results-counter {
  color: rgba(232, 240, 255, 0.8);
  font-size: 0.9rem;
  font-family: "Rajdhani", sans-serif;
  margin-left: 1rem;
  padding: 0.5rem 1rem;
  background: rgba(77, 212, 255, 0.1);
  border-radius: 20px;
  border: 1px solid rgba(77, 212, 255, 0.2);
  backdrop-filter: blur(5px);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(77, 212, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 15px rgba(77, 212, 255, 0.4);
  }
}

.factions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.faction-card {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.95),
    rgba(10, 14, 39, 0.95)
  );
  border: 2px solid rgba(77, 212, 255, 0.4);
  border-radius: 24px;
  padding: 2rem;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 8px 32px rgba(77, 212, 255, 0.15);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: visible;
  backdrop-filter: blur(15px);
}

.faction-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(77, 212, 255, 0.1),
    transparent
  );
  transition: left 0.5s ease;
  pointer-events: none;
  z-index: 0;
}

.faction-card:hover::before {
  left: 100%;
}

.faction-card > * {
  position: relative;
  z-index: 1;
}

.faction-card:hover {
  transform: translateY(-12px) scale(1.03);
  box-shadow:
    0 30px 80px rgba(77, 212, 255, 0.3),
    0 0 0 1px rgba(77, 212, 255, 0.5) inset,
    0 0 40px rgba(77, 212, 255, 0.4);
  border-color: rgba(77, 212, 255, 0.8);
}

.faction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faction-header h2 {
  font-family: "Cinzel", serif;
  font-size: 1.65rem;
  background: linear-gradient(135deg, #4dd4ff, #6ee7ff, #ffd700);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(77, 212, 255, 0.4));
  transition: all 0.3s ease;
  position: relative;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  font-weight: 700;
  animation: gradientShift 4s ease infinite;
}

.faction-card:hover .faction-header h2 {
  transform: translateX(5px);
  filter: brightness(1.2);
}

.faction-tag {
  padding: 0.5rem 1.2rem;
  border-radius: 25px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  transition: all 0.3s ease;
  box-shadow: 0 3px 15px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
}

.faction-tag::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition:
    width 0.3s ease,
    height 0.3s ease;
  z-index: 0;
}

.faction-card:hover .faction-tag::before {
  width: 100%;
  height: 100%;
}

.faction-tag.nation {
  background: rgba(77, 212, 255, 0.2);
  color: #4dd4ff;
  position: relative;
  z-index: 1;
}

.faction-tag.nation::before {
  z-index: -1;
}

.faction-tag.council {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
}

.faction-tag.military {
  background: rgba(255, 99, 71, 0.2);
  color: #ff6347;
}

.faction-tag.guild {
  background: rgba(144, 238, 144, 0.2);
  color: #90ee90;
}

.faction-summary {
  margin: 1.2rem 0;
  color: rgba(232, 240, 255, 0.95);
  line-height: 1.7;
  font-size: 1rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.expand-btn {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.15),
    rgba(77, 212, 255, 0.08)
  );
  border: 2px solid rgba(77, 212, 255, 0.5);
  color: #4dd4ff;
  padding: 0.85rem 1.8rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 700;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  font-size: 0.85rem;
}

.expand-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(77, 212, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition:
    width 0.4s ease,
    height 0.4s ease;
}

.expand-btn:hover::before {
  width: 300px;
  height: 300px;
}

.expand-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.35),
    rgba(77, 212, 255, 0.2)
  );
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(77, 212, 255, 0.5);
  border-color: rgba(77, 212, 255, 1);
}

.expand-btn:active {
  transform: translateY(0);
}

/* mobile responsive design */
@media (max-width: 767px) {
  .factions-container {
    padding: 1.5rem 1rem 3rem;
    padding-top: 2rem; /* Reduced since navbar is no longer fixed */
  }

  .page-title {
    font-size: 2.2rem;
    line-height: 1.2;
  }

  .page-subtitle {
    font-size: 1rem;
    margin: 1rem auto 0;
    padding: 0 1rem;
  }

  .factions-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(21, 27, 61, 0.4);
    border-radius: 15px;
    border: 1px solid rgba(77, 212, 255, 0.2);
    margin-bottom: 2rem;
  }

  .factions-controls input,
  .factions-controls select {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0.9rem 1rem;
    font-size: 0.9rem;
    min-height: 44px; /* Touch-friendly */
    touch-action: manipulation;
  }

  .results-counter {
    text-align: center;
    margin: 1rem 0 0 0;
    font-size: 0.85rem;
  }

  .factions-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 0 0.5rem;
  }

  .faction-card {
    padding: 1.5rem;
    border-radius: 15px;
  }

  .faction-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
  }

  .faction-header h2 {
    font-size: 1.4rem;
    line-height: 1.3;
    margin: 0;
    width: 100%;
    word-break: break-word;
  }

  .faction-tag {
    padding: 0.4rem 0.9rem;
    font-size: 0.7rem;
    border-radius: 15px;
    align-self: flex-start;
  }

  .faction-summary {
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 1rem 0;
  }

  .expand-btn {
    width: 100%;
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
    min-height: 44px;
    touch-action: manipulation;
    border-radius: 10px;
  }

  /* Power snapshot mobile optimization */
  .power-snapshot {
    margin: 1rem 0;
    gap: 0.5rem;
  }

  .power-item {
    grid-template-columns: 70px 1fr;
    gap: 0.5rem;
    font-size: 0.8rem;
  }

  .power-bar {
    height: 6px;
  }

  /* Quick filters mobile layout */
  .quick-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .quick-filter {
    width: 100%;
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    min-height: 44px;
    touch-action: manipulation;
  }

  /* Disable hover effects on touch devices */
  .faction-card:hover {
    transform: none;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  }

  .expand-btn:hover {
    transform: none;
  }

  /* Touch-friendly interactions */
  .faction-card {
    -webkit-tap-highlight-color: rgba(77, 212, 255, 0.1);
    touch-action: manipulation;
  }

  .expand-btn {
    -webkit-tap-highlight-color: rgba(77, 212, 255, 0.2);
  }

  /* Performance optimizations */
  .magic-circle,
  .particles,
  .starfield {
    display: none !important;
  }

  /* Reduce animations for better performance */
  .faction-card {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
  }

  /* Improve text readability */
  .faction-header h2,
  .faction-summary,
  .detail-section {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
}

/* Small phone optimizations */
@media (max-width: 479px) {
  .factions-container {
    padding: 1rem 0.75rem 2rem;
    padding-top: 1.5rem;
  }

  .page-title {
    font-size: 1.8rem;
  }

  .page-subtitle {
    font-size: 0.9rem;
    padding: 0 0.5rem;
  }

  .factions-controls {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  .factions-controls input,
  .factions-controls select {
    padding: 0.8rem;
    font-size: 0.85rem;
  }

  .factions-grid {
    gap: 1rem;
    padding: 0 0.25rem;
  }

  .faction-card {
    padding: 1.25rem;
  }

  .faction-header h2 {
    font-size: 1.2rem;
  }

  .faction-tag {
    padding: 0.3rem 0.7rem;
    font-size: 0.65rem;
  }

  .faction-summary {
    font-size: 0.9rem;
  }

  .expand-btn {
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
  }

  .power-item {
    grid-template-columns: 60px 1fr;
    font-size: 0.75rem;
  }

  .power-bar {
    height: 5px;
  }
}

/* Tablet layout adjustments */
@media (min-width: 768px) {
  .factions-container {
    padding: 2rem;
    padding-top: 2rem;
  }

  .page-title {
    font-size: 2.8rem;
  }

  .factions-controls {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
  }

  .factions-controls input,
  .factions-controls select {
    width: auto;
    max-width: 250px;
  }

  .factions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .faction-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Desktop optimizations */
@media (min-width: 1024px) {
  .factions-container {
    max-width: 1400px;
    padding: 3rem;
    padding-top: 2rem;
  }

  .page-title {
    font-size: 3.2rem;
  }

  .factions-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  }
}

/* Mobile performance optimizations and accessibility */
@media (max-width: 767px) {
  /* Enable smooth scrolling on mobile */
  body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Optimize touch interactions */
  .faction-card,
  .expand-btn,
  .quick-filter,
  .factions-controls input,
  .factions-controls select {
    -webkit-tap-highlight-color: rgba(77, 212, 255, 0.1);
  }

  /* Improve focus visibility for accessibility */
  .expand-btn:focus,
  .quick-filter:focus,
  .factions-controls input:focus,
  .factions-controls select:focus {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
  }

  /* Ensure proper text wrapping */
  .faction-header h2,
  .faction-summary,
  .detail-section li {
    word-break: break-word;
    hyphens: auto;
  }

  /* Mobile-specific loading states */
  .faction-card.loading {
    opacity: 0.6;
    pointer-events: none;
  }

  /* Better error handling on mobile */
  .faction-error {
    padding: 2rem 1rem;
    text-align: center;
    background: rgba(255, 99, 71, 0.1);
    border: 1px solid rgba(255, 99, 71, 0.2);
    border-radius: 12px;
    margin: 1rem 0;
  }
}

/* Accessibility support for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .faction-card,
  .expand-btn,
  .quick-filter {
    animation: none !important;
    transition: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .faction-card {
    border: 2px solid;
  }

  .faction-tag {
    border: 1px solid;
  }

  .expand-btn {
    border: 2px solid;
  }
}

/* ===== Mini Faction Timeline ===== */
.mini-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.timeline-node {
  padding: 0.6rem;
  border-radius: 10px;
  background: rgba(77, 212, 255, 0.1);
  border: 1px solid rgba(77, 212, 255, 0.25);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  opacity: 0.7;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.timeline-node::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(77, 212, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.timeline-node:hover::before {
  left: 100%;
}

.timeline-node.active {
  opacity: 1;
  box-shadow: 0 0 15px rgba(77, 212, 255, 0.5);
  background: rgba(77, 212, 255, 0.15);
}

.timeline-node.current {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.3),
    rgba(255, 215, 0, 0.2)
  );
  border-color: rgba(255, 215, 0, 0.6);
  opacity: 1;
  animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  }
}

.timeline-node span {
  display: block;
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: #4dd4ff;
}

.timeline-node small {
  display: block;
  font-size: 0.65rem;
  color: rgba(232, 240, 255, 0.8);
  line-height: 1.2;
}

.timeline-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(77, 212, 255, 0.3);
}

/* Mobile timeline adjustments */
@media (max-width: 767px) {
  .mini-timeline {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .timeline-node {
    padding: 0.5rem;
    font-size: 0.7rem;
  }

  .timeline-node small {
    font-size: 0.6rem;
  }
}

/* Modal-specific timeline styling */
.modal-detail-section .mini-timeline {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.modal-detail-section.timeline-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.4),
    rgba(10, 14, 39, 0.4)
  );
  border: 2px solid rgba(77, 212, 255, 0.4);
  border-radius: 18px;
  margin-bottom: 2rem;
}

.modal-detail-section.timeline-section h4 {
  color: #ffd700;
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.modal-detail-section .timeline-node {
  background: rgba(77, 212, 255, 0.15);
  border: 1px solid rgba(77, 212, 255, 0.3);
  transition: all 0.3s ease;
}

.modal-detail-section .timeline-node:hover {
  background: rgba(77, 212, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(77, 212, 255, 0.4);
}

.modal-detail-section .timeline-node.active {
  background: rgba(77, 212, 255, 0.2);
  border-color: rgba(77, 212, 255, 0.5);
  box-shadow: 0 0 15px rgba(77, 212, 255, 0.5);
}

.modal-detail-section .timeline-node.current {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.4),
    rgba(255, 215, 0, 0.3)
  );
  border-color: rgba(255, 215, 0, 0.7);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

/* Timeline animation in modal */
.modal-detail-section .timeline-node {
  animation: timelineSlideIn 0.4s ease-out forwards;
  opacity: 0;
  transform: translateY(20px);
}

.modal-detail-section .timeline-node:nth-child(1) {
  animation-delay: 0.1s;
}
.modal-detail-section .timeline-node:nth-child(2) {
  animation-delay: 0.2s;
}
.modal-detail-section .timeline-node:nth-child(3) {
  animation-delay: 0.3s;
}
.modal-detail-section .timeline-node:nth-child(4) {
  animation-delay: 0.4s;
}

@keyframes timelineSlideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* faction details styling */
.faction-details ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.faction-details li {
  margin-bottom: 0.8rem;
  color: rgba(232, 240, 255, 0.9);
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(77, 212, 255, 0.1);
}

.faction-details li:last-child {
  border-bottom: none;
}

.faction-details strong {
  color: #4dd4ff;
  font-weight: 600;
}
/*  faction detail sections */
.detail-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(77, 212, 255, 0.1);
}

.detail-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.detail-section h4 {
  color: #ffd700;
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-section ul {
  margin-top: 0.5rem;
}

/* Race faction styling */
.faction-tag.race {
  background: rgba(186, 85, 211, 0.2);
  color: #ba55d3;
}

/* Relation-based styling */
.faction-card[data-relation="allied"] {
  border-left: 4px solid #90ee90;
}

.faction-card[data-relation="hostile"] {
  border-left: 4px solid #ff6347;
}

.faction-card[data-relation="neutral"] {
  border-left: 4px solid #ffd700;
}

.faction-card[data-relation="unknown"] {
  border-left: 4px solid #808080;
}

.factions-controls input::placeholder {
  color: rgba(232, 240, 255, 0.5);
}

/*  mobile responsiveness for detail sections */
@media (max-width: 768px) {
  .detail-section h4 {
    font-size: 1rem;
  }

  .detail-section {
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
  }
}
/* Quick filter buttons */
.quick-filters {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.quick-filter {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(77, 212, 255, 0.3);
  background: rgba(21, 27, 61, 0.4);
  color: #4dd4ff;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Rajdhani", sans-serif;
}

.quick-filter:hover {
  background: rgba(77, 212, 255, 0.1);
  border-color: rgba(77, 212, 255, 0.5);
  transform: translateY(-1px);
}

.quick-filter:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .quick-filters {
    flex-direction: column;
    align-items: center;
  }

  .quick-filter {
    width: 100%;
    max-width: 200px;
  }
}
/* ===== Faction Power Snapshot ===== */
.power-snapshot {
  margin: 1.2rem 0;
  display: grid;
  gap: 0.6rem;
}

.power-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: rgba(232, 240, 255, 0.8);
}

.power-bar {
  height: 10px;
  background: linear-gradient(
    90deg,
    rgba(10, 14, 39, 0.8),
    rgba(77, 212, 255, 0.15)
  );
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) inset;
  border: 1px solid rgba(77, 212, 255, 0.2);
}

.power-bar div {
  height: 100%;
  width: calc(var(--power) * 1%);
  background: linear-gradient(90deg, #4dd4ff, #6ee7ff, #ffd700);
  box-shadow:
    0 0 15px rgba(77, 212, 255, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  transition: width 1s cubic-bezier(0.65, 0, 0.35, 1);
  position: relative;
  overflow: hidden;
}

.power-bar div::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/*  power bar animations */
.faction-card:hover .power-bar div {
  box-shadow: 0 0 12px rgba(77, 212, 255, 0.8);
}

/* Power level color variations */
.power-bar div[style*="--power: 9"],
.power-bar div[style*="--power: 10"] {
  background: linear-gradient(90deg, #ffd700, #ff6b35);
}

.power-bar div[style*="--power: 8"] {
  background: linear-gradient(90deg, #4dd4ff, #ffd700);
}

.power-bar div[style*="--power: 7"] {
  background: linear-gradient(90deg, #4dd4ff, #90ee90);
}

.power-bar div[style*="--power: 6"],
.power-bar div[style*="--power: 5"] {
  background: linear-gradient(90deg, #90ee90, #87ceeb);
}
/* Special styling for fallen/dissolved factions */
.faction-card[data-type="nation"]:has(h2:contains("Fallen")) .power-bar,
.faction-card h2:contains("Fallen") ~ .power-snapshot .power-bar {
  background: rgba(255, 99, 71, 0.15);
}

.faction-card h2:contains("Fallen") ~ .power-snapshot .power-bar div {
  background: linear-gradient(90deg, #ff6347, #8b0000);
  box-shadow: 0 0 8px rgba(255, 99, 71, 0.4);
}

/*  power bar for trade/economic factions */
.faction-card[data-type="guild"]
  .power-snapshot
  .power-item:nth-child(2)
  .power-bar
  div {
  background: linear-gradient(90deg, #90ee90, #ffd700);
  box-shadow: 0 0 10px rgba(144, 238, 144, 0.6);
}

/* Race faction power bar styling */
.faction-card[data-type="race"] .power-snapshot .power-bar div {
  background: linear-gradient(90deg, #ba55d3, #9370db);
  box-shadow: 0 0 8px rgba(186, 85, 211, 0.5);
}
/* ========== FACTION MODAL ========== */
.faction-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1010;
  align-items: center;
  justify-content: center;
  padding-top: 80px;
  box-sizing: border-box;
}

.faction-modal.active {
  display: flex;
}

.faction-modal .modal-content {
  background: linear-gradient(
    145deg,
    rgba(21, 25, 35, 0.98),
    rgba(35, 53, 80, 0.95)
  );
  border: 2px solid rgba(77, 212, 255, 0.5);
  border-radius: 28px;
  padding: 0;
  max-width: 950px;
  max-height: 85vh;
  overflow: hidden;
  position: relative;
  margin: 2rem 1rem 1rem 1rem;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(77, 212, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: modalSlideIn 0.3s ease-out;
  backdrop-filter: blur(20px);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.faction-modal .modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 87, 87, 0.15);
  border: 2px solid rgba(255, 87, 87, 0.3);
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 45px;
  height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 1020;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.faction-modal .modal-close:hover {
  background: rgba(255, 87, 87, 0.3);
  border-color: #ff5757;
  color: #ff5757;
  transform: rotate(90deg) scale(1.15);
  box-shadow: 0 6px 20px rgba(255, 87, 87, 0.4);
}

.faction-modal .modal-close:active {
  transform: rotate(90deg) scale(1.05);
}

.faction-modal .modal-body {
  padding: 2rem;
  overflow-y: auto;
  max-height: 85vh;
}

/* Modal faction header */
.modal-faction-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid rgba(77, 212, 255, 0.3);
}

.modal-faction-title {
  font-family: "Cinzel", serif;
  font-size: 2.5rem;
  background: linear-gradient(135deg, #4dd4ff, #6ee7ff, #ffd700);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
  font-weight: 700;
  animation: gradientShift 4s ease infinite;
  filter: drop-shadow(0 0 20px rgba(77, 212, 255, 0.5));
}

.modal-faction-tag {
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 0.9rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-faction-summary {
  font-size: 1.15rem;
  color: rgba(232, 240, 255, 0.95);
  line-height: 1.7;
  margin-bottom: 2rem;
  font-style: italic;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Modal power snapshot */
.modal-power-snapshot {
  background: rgba(21, 27, 61, 0.4);
  border: 1px solid rgba(77, 212, 255, 0.2);
  border-radius: 15px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.modal-power-snapshot h3 {
  color: #ffd700;
  font-family: "Cinzel", serif;
  margin-bottom: 1rem;
  text-align: center;
}

.modal-power-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.modal-power-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-power-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: rgba(232, 240, 255, 0.9);
}

.modal-power-value {
  font-size: 0.9rem;
  color: #4dd4ff;
  font-weight: bold;
}

.modal-power-bar {
  height: 12px;
  background: rgba(77, 212, 255, 0.15);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.modal-power-bar div {
  height: 100%;
  background: linear-gradient(90deg, #4dd4ff, #ffd700);
  border-radius: 10px;
  transition: width 1s cubic-bezier(0.65, 0, 0.35, 1);
  box-shadow: 0 0 15px rgba(77, 212, 255, 0.6);
  position: relative;
  overflow: hidden;
}

.modal-power-bar div::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.5),
    transparent
  );
  animation: shimmer 2.5s infinite;
}

.modal-detail-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.modal-detail-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.4),
    rgba(10, 14, 39, 0.4)
  );
  border: 1px solid rgba(77, 212, 255, 0.25);
  border-radius: 15px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.modal-detail-section:hover {
  border-color: rgba(77, 212, 255, 0.4);
  box-shadow: 0 6px 20px rgba(77, 212, 255, 0.15);
  transform: translateY(-2px);
}

.modal-detail-section h4 {
  color: #ffd700;
  font-family: "Cinzel", serif;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.modal-detail-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.modal-detail-section li {
  margin-bottom: 0.8rem;
  color: rgba(232, 240, 255, 0.9);
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(77, 212, 255, 0.1);
  line-height: 1.5;
}

.modal-detail-section li:last-child {
  border-bottom: none;
}

.modal-detail-section strong {
  color: #4dd4ff;
  font-weight: 600;
}

/* Modal links section styling */
.modal-detail-section .faction-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.modal-detail-section .faction-link {
  padding: 0.4rem 0.8rem;
  border-radius: 14px;
  background: rgba(77, 212, 255, 0.15);
  border: 1px solid rgba(77, 212, 255, 0.3);
  color: #4dd4ff;
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.25s ease;
}

.modal-detail-section .faction-link:hover {
  background: rgba(77, 212, 255, 0.3);
  transform: translateY(-1px);
}

/* Mobile responsiveness for modal */
@media (max-width: 767px) {
  .faction-modal .modal-content {
    margin: 0.5rem;
    max-height: 95vh;
    border-radius: 16px;
  }

  .faction-modal .modal-body {
    padding: 1.5rem;
    max-height: 85vh;
  }

  .modal-faction-header {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .modal-faction-title {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  .modal-faction-tag {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  .modal-faction-summary {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }

  .modal-power-snapshot {
    padding: 1.25rem;
    margin-bottom: 1.5rem;
  }

  .modal-power-grid {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .modal-power-bar {
    height: 10px;
  }

  .modal-detail-sections {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .modal-detail-section {
    padding: 1.25rem;
  }

  .modal-detail-section h4 {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
  }

  .modal-detail-section li {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.6rem;
  }

  .modal-detail-section .faction-links {
    gap: 0.5rem;
  }

  .modal-detail-section .faction-link {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  /* Mobile timeline in modal */
  .modal-detail-section .mini-timeline {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin: 1rem 0;
  }

  .modal-detail-section .timeline-node {
    padding: 0.6rem;
    font-size: 0.75rem;
  }

  .modal-detail-section .timeline-node span {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
  }

  .modal-detail-section .timeline-node small {
    font-size: 0.65rem;
  }
}

@media (max-width: 479px) {
  .faction-modal .modal-content {
    margin: 0.25rem;
    max-height: 98vh;
  }

  .faction-modal .modal-body {
    padding: 1rem;
    max-height: 88vh;
  }

  .modal-faction-title {
    font-size: 1.5rem;
  }

  .modal-faction-summary {
    font-size: 0.95rem;
  }

  .modal-power-snapshot {
    padding: 1rem;
  }

  .modal-detail-section {
    padding: 1rem;
  }

  .modal-detail-section h4 {
    font-size: 1rem;
  }

  .modal-detail-section li {
    font-size: 0.85rem;
  }
}
/* Hide faction details completely on cards - they should only appear in modal */
.faction-card .faction-details {
  display: none !important;
}

.faction-details {
  display: none !important;
}

/* ===== Dependency Indicators ===== */
.dependency-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.dependency-grid span {
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem;
  border-radius: 10px;
  background: rgba(77, 212, 255, 0.15);
  border: 1px solid rgba(77, 212, 255, 0.3);
  color: var(--text-light);
  transition: all 0.3s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.dependency-grid span::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(77, 212, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.dependency-grid span:hover::before {
  left: 100%;
}

.dependency-grid span:hover {
  background: rgba(77, 212, 255, 0.25);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(77, 212, 255, 0.3);
}

/* Mobile dependency grid adjustments */
@media (max-width: 767px) {
  .dependency-grid {
    gap: 0.5rem;
  }

  .dependency-grid span {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }
}

/* ===== Cross Links ===== */
.faction-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.faction-link {
  padding: 0.4rem 0.8rem;
  border-radius: 14px;
  background: rgba(77, 212, 255, 0.15);
  border: 1px solid rgba(77, 212, 255, 0.3);
  color: #4dd4ff;
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.25s ease;
}

.faction-link:hover {
  background: rgba(77, 212, 255, 0.3);
  transform: translateY(-1px);
}

/* ===== Federation Impact ===== */
.impact-section ul li {
  padding-left: 1.2rem;
  position: relative;
}

.impact-positive::before {
  content: "▲";
  color: #90ee90;
  position: absolute;
  left: 0;
}

.impact-negative::before {
  content: "▼";
  color: #ff6347;
  position: absolute;
  left: 0;
}

.impact-neutral::before {
  content: "●";
  color: #ffd700;
  position: absolute;
  left: 0;
}

/* ===== Faction Relations Pills ===== */
.relation-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.relation {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.relation::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition:
    width 0.3s ease,
    height 0.3s ease;
}

.relation:hover::before {
  width: 150px;
  height: 150px;
}

.relation:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.relation.allied {
  background: rgba(144, 238, 144, 0.25);
  color: #90ee90;
  border-color: rgba(144, 238, 144, 0.4);
}

.relation.allied:hover {
  background: rgba(144, 238, 144, 0.35);
  box-shadow: 0 2px 8px rgba(144, 238, 144, 0.3);
}

.relation.neutral {
  background: rgba(255, 215, 0, 0.25);
  color: #ffd700;
  border-color: rgba(255, 215, 0, 0.4);
}

.relation.neutral:hover {
  background: rgba(255, 215, 0, 0.35);
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.relation.hostile {
  background: rgba(255, 99, 71, 0.25);
  color: #ff6347;
  border-color: rgba(255, 99, 71, 0.4);
}

.relation.hostile:hover {
  background: rgba(255, 99, 71, 0.35);
  box-shadow: 0 2px 8px rgba(255, 99, 71, 0.3);
}

.relation.unknown {
  background: rgba(128, 128, 128, 0.25);
  color: #808080;
  border-color: rgba(128, 128, 128, 0.4);
}

.relation.unknown:hover {
  background: rgba(128, 128, 128, 0.35);
  box-shadow: 0 2px 8px rgba(128, 128, 128, 0.3);
}

/* Relations section styling */
.relations-section {
  background: rgba(21, 27, 61, 0.2);
  border: 1px solid rgba(77, 212, 255, 0.2);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
}

.relations-section h4 {
  color: #4dd4ff;
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
  margin-bottom: 0.8rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Modal Relations Legend */
.modal-relations-legend {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: rgba(10, 14, 39, 0.4);
  border-radius: 8px;
  border: 1px solid rgba(77, 212, 255, 0.1);
}

.modal-legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.modal-legend-item small {
  color: rgba(232, 240, 255, 0.7);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* Mobile responsiveness for modal legend */
@media (max-width: 767px) {
  .modal-relations-legend {
    flex-wrap: wrap;
    gap: 0.6rem;
    padding: 0.6rem;
  }

  .modal-legend-item {
    gap: 0.2rem;
  }

  .modal-legend-item small {
    font-size: 0.6rem;
  }

  .modal-legend-item .relation {
    padding: 0.2rem 0.5rem;
    font-size: 0.6rem;
  }
}

/* Mobile responsiveness for relation pills */
@media (max-width: 767px) {
  .relation-pills {
    gap: 0.4rem;
    justify-content: center;
  }

  .relation {
    padding: 0.25rem 0.6rem;
    font-size: 0.65rem;
  }

  .relations-section {
    padding: 1rem;
    margin-bottom: 1.2rem;
  }

  .relations-section h4 {
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }
}

/* =====  Faction Card Hover Stats ===== */
.faction-card {
  position: relative;
}

.faction-card::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #4dd4ff, #ffd700, #ff6b9d, #4dd4ff);
  background-size: 300% 300%;
  border-radius: 20px;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.3s ease;
  animation: gradientRotate 4s ease infinite;
}

.faction-card:hover::after {
  opacity: 0.3;
}

@keyframes gradientRotate {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* ===== Power Item  Styling ===== */
.power-item span {
  font-weight: 600;
  color: rgba(232, 240, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.8rem;
}

/* ===== Faction Summary  ===== */
.faction-summary {
  margin: 1rem 0;
  color: rgba(232, 240, 255, 0.9);
  line-height: 1.7;
  font-size: 0.95rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* =====  Modal Animations ===== */
.faction-modal.active {
  animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-faction-title {
  position: relative;
  display: inline-block;
}

.modal-faction-title::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    #4dd4ff,
    #ffd700,
    transparent
  );
  animation: titleUnderline 2s ease-in-out infinite;
}

@keyframes titleUnderline {
  0%,
  100% {
    opacity: 0.5;
    transform: scaleX(0.8);
  }
  50% {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* ===== Scrollbar Styling for Modal ===== */
.faction-modal .modal-body::-webkit-scrollbar {
  width: 8px;
}

.faction-modal .modal-body::-webkit-scrollbar-track {
  background: rgba(10, 14, 39, 0.5);
  border-radius: 10px;
}

.faction-modal .modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4dd4ff, #ffd700);
  border-radius: 10px;
  transition: background 0.3s ease;
}

.faction-modal .modal-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffd700, #4dd4ff);
}

/* =====  Impact Section ===== */
.impact-section ul li {
  padding: 0.5rem 0.5rem 0.5rem 1.5rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.impact-section ul li:hover {
  background: rgba(77, 212, 255, 0.05);
  transform: translateX(5px);
}

.impact-positive {
  border-left: 3px solid #90ee90;
}

.impact-negative {
  border-left: 3px solid #ff6347;
}

.impact-neutral {
  border-left: 3px solid #ffd700;
}

/* =====  Detail Section Headers ===== */
.detail-section h4,
.modal-detail-section h4 {
  position: relative;
  padding-bottom: 0.5rem;
}

.detail-section h4::after,
.modal-detail-section h4::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ffd700, transparent);
  border-radius: 2px;
}

/* ===== Faction Type Specific Enhancements ===== */
.faction-card[data-type="nation"]:hover {
  border-color: rgba(77, 212, 255, 0.7);
}

.faction-card[data-type="council"]:hover {
  border-color: rgba(255, 215, 0, 0.7);
}

.faction-card[data-type="military"]:hover {
  border-color: rgba(255, 99, 71, 0.7);
}

.faction-card[data-type="guild"]:hover {
  border-color: rgba(144, 238, 144, 0.7);
}

.faction-card[data-type="race"]:hover {
  border-color: rgba(186, 85, 211, 0.7);
}

/* ===== Loading State Enhancement ===== */
.faction-card.loading {
  opacity: 0.5;
  pointer-events: none;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.7;
  }
}

/* ===== No Results Message ===== */
.no-results {
  text-align: center;
  padding: 3rem;
  color: rgba(232, 240, 255, 0.6);
  font-size: 1.2rem;
  font-family: "Cinzel", serif;
}

.no-results::before {
  content: "🔍";
  display: block;
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* ===== Scroll to Top Button ===== */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.9),
    rgba(77, 212, 255, 0.7)
  );
  border: 2px solid rgba(77, 212, 255, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(77, 212, 255, 0.3);
  backdrop-filter: blur(10px);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 6px 20px rgba(77, 212, 255, 0.5);
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 1),
    rgba(77, 212, 255, 0.9)
  );
}

.scroll-to-top::before {
  content: "↑";
  font-size: 1.5rem;
  color: #fff;
  font-weight: bold;
}

/* =====  Modal Content Animation ===== */
.modal-detail-sections {
  animation: fadeInStagger 0.6s ease-out;
}

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

.modal-detail-section:nth-child(1) {
  animation-delay: 0.1s;
}
.modal-detail-section:nth-child(2) {
  animation-delay: 0.15s;
}
.modal-detail-section:nth-child(3) {
  animation-delay: 0.2s;
}
.modal-detail-section:nth-child(4) {
  animation-delay: 0.25s;
}
.modal-detail-section:nth-child(5) {
  animation-delay: 0.3s;
}
.modal-detail-section:nth-child(6) {
  animation-delay: 0.35s;
}

/* ===== Faction Card Relation Border Glow ===== */
.faction-card[data-relation="allied"] {
  border-left: 4px solid #90ee90;
  box-shadow: -4px 0 15px rgba(144, 238, 144, 0.2);
}

.faction-card[data-relation="hostile"] {
  border-left: 4px solid #ff6347;
  box-shadow: -4px 0 15px rgba(255, 99, 71, 0.2);
}

.faction-card[data-relation="neutral"] {
  border-left: 4px solid #ffd700;
  box-shadow: -4px 0 15px rgba(255, 215, 0, 0.2);
}

.faction-card[data-relation="unknown"] {
  border-left: 4px solid #808080;
  box-shadow: -4px 0 15px rgba(128, 128, 128, 0.2);
}

/* =====  Modal Power Snapshot ===== */
.modal-power-snapshot {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.5),
    rgba(10, 14, 39, 0.5)
  );
  border: 2px solid rgba(77, 212, 255, 0.3);
  border-radius: 15px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.modal-power-snapshot h3 {
  color: #ffd700;
  font-family: "Cinzel", serif;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.4rem;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  letter-spacing: 1px;
}

/* =====  Faction Header ===== */
.faction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(77, 212, 255, 0.15);
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== Search Input Enhancement ===== */
.factions-controls input[type="text"] {
  min-width: 250px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%234dd4ff" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: 12px center;
  padding-left: 2.5rem;
}

/* ===== Select Dropdown Enhancement ===== */
.factions-controls select {
  cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="%234dd4ff" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: calc(100% - 12px) center;
  padding-right: 2.5rem;
}

/* =====  Faction Summary ===== */
.faction-summary {
  position: relative;
  padding-left: 1rem;
  border-left: 3px solid rgba(77, 212, 255, 0.3);
}

/* =====  Timeline Section ===== */
.timeline-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.5),
    rgba(10, 14, 39, 0.5)
  );
  border: 2px solid rgba(77, 212, 255, 0.3);
  padding: 1.5rem;
  border-radius: 15px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.timeline-section h4 {
  text-align: center;
  margin-bottom: 1.2rem;
  font-size: 1.2rem;
}

/* ===== Responsive Enhancements ===== */
@media (max-width: 767px) {
  .scroll-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 45px;
    height: 45px;
  }

  .scroll-to-top::before {
    font-size: 1.3rem;
  }
}

/* ===== Active Filter Indicators ===== */
.factions-controls select:not([value="all"]),
.factions-controls input:not(:placeholder-shown) {
  border-color: rgba(255, 215, 0, 0.6);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.factions-controls select:not([value="all"])::after,
.factions-controls input:not(:placeholder-shown)::after {
  content: "✓";
  position: absolute;
  right: 10px;
  color: #ffd700;
}

/* ===== Clear Filters Button ===== */
.clear-filters-btn {
  padding: 0.8rem 1.2rem;
  border-radius: 12px;
  border: 2px solid rgba(255, 99, 71, 0.4);
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.1),
    rgba(255, 99, 71, 0.05)
  );
  color: #ff6347;
  font-family: "Rajdhani", sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  display: none;
}

.clear-filters-btn.visible {
  display: block;
}

.clear-filters-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.25),
    rgba(255, 99, 71, 0.15)
  );
  border-color: rgba(255, 99, 71, 0.8);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 99, 71, 0.3);
}

.clear-filters-btn:active {
  transform: translateY(0);
}

/* ===== Faction Card States ===== */
.faction-card.filtered-out {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}

.faction-card.filtered-in {
  opacity: 1;
  transform: scale(1);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

/* =====  Modal Header ===== */
.modal-faction-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid rgba(77, 212, 255, 0.3);
  position: relative;
}

.modal-faction-header::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    #4dd4ff,
    #ffd700,
    transparent
  );
  animation: headerGlow 3s ease-in-out infinite;
}

@keyframes headerGlow {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

/* ===== Tooltip for Power Stats ===== */
.power-item {
  position: relative;
  cursor: help;
}

.power-item::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  background: rgba(10, 14, 39, 0.95);
  color: #e8f0ff;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
  border: 1px solid rgba(77, 212, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.power-item:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

/* =====  Faction Links ===== */
.faction-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.links-section {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.05),
    rgba(10, 14, 39, 0.3)
  );
  border: 1px solid rgba(77, 212, 255, 0.2);
  border-radius: 12px;
  padding: 1.2rem;
}

/* ===== Faction Card Quick Actions ===== */
.faction-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(77, 212, 255, 0.15);
}

.quick-action-btn {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(77, 212, 255, 0.3);
  background: rgba(77, 212, 255, 0.05);
  color: #4dd4ff;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.quick-action-btn:hover {
  background: rgba(77, 212, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(77, 212, 255, 0.2);
}

/* =====  Page Transitions ===== */
@keyframes pageLoad {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.factions-container {
  animation: pageLoad 0.6s ease-out;
}

/* =====  Mobile Touch Feedback ===== */
@media (max-width: 767px) {
  .faction-card:active {
    transform: scale(0.98);
  }

  .expand-btn:active {
    transform: scale(0.95);
  }

  .relation:active {
    transform: scale(0.95);
  }
}

/* ===== Print Styles ===== */
@media print {
  .factions-controls,
  .scroll-to-top,
  .expand-btn,
  .main-nav,
  .mobile-nav,
  .starfield,
  .particles {
    display: none !important;
  }

  .faction-card {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }

  .faction-details {
    display: block !important;
  }
}

/*  Faction Header */
.faction-header h2 {
  font-size: 1.6rem !important;
  filter: drop-shadow(0 0 20px rgba(77, 212, 255, 0.4)) !important;
  font-weight: 700 !important;
  letter-spacing: 1px !important;
}

.factions-controls input,
.factions-controls select {
  padding: 1rem 1.5rem !important;
  border-radius: 14px !important;
  border: 2px solid rgba(77, 212, 255, 0.4) !important;
  background: rgba(10, 14, 39, 0.9) !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.2) inset !important;
}

.factions-controls input:focus,
.factions-controls select:focus {
  border-color: #4dd4ff !important;
  background: rgba(10, 14, 39, 1) !important;
  box-shadow:
    0 0 30px rgba(77, 212, 255, 0.6),
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 0 0 4px rgba(77, 212, 255, 0.1) !important;
  transform: translateY(-3px) scale(1.02) !important;
}

.power-bar {
  height: 10px !important;
  background: linear-gradient(
    90deg,
    rgba(10, 14, 39, 0.8),
    rgba(77, 212, 255, 0.15)
  ) !important;
  border-radius: 12px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) inset !important;
  border: 1px solid rgba(77, 212, 255, 0.2) !important;
}

.power-bar div {
  background: linear-gradient(
    90deg,
    #4dd4ff 0%,
    #5de4ff 50%,
    #ffd700 100%
  ) !important;
  box-shadow:
    0 0 15px rgba(77, 212, 255, 0.8),
    0 0 30px rgba(77, 212, 255, 0.4) !important;
  border-radius: 12px !important;
}

/* Faction Tags */
.faction-tag {
  padding: 0.5rem 1.2rem !important;
  border-radius: 25px !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  letter-spacing: 1.2px !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(10px) !important;
}

.faction-tag.nation {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.3),
    rgba(77, 212, 255, 0.15)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.5) !important;
}

.faction-tag.council {
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.3),
    rgba(255, 215, 0, 0.15)
  ) !important;
  border: 2px solid rgba(255, 215, 0, 0.5) !important;
}

.faction-tag.military {
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.3),
    rgba(255, 99, 71, 0.15)
  ) !important;
  border: 2px solid rgba(255, 99, 71, 0.5) !important;
}

.faction-tag.guild {
  background: linear-gradient(
    135deg,
    rgba(144, 238, 144, 0.3),
    rgba(144, 238, 144, 0.15)
  ) !important;
  border: 2px solid rgba(144, 238, 144, 0.5) !important;
}

.faction-tag.race {
  background: linear-gradient(
    135deg,
    rgba(186, 85, 211, 0.3),
    rgba(186, 85, 211, 0.15)
  ) !important;
  border: 2px solid rgba(186, 85, 211, 0.5) !important;
}

.modal-faction-title {
  font-size: 2.5rem !important;
  filter: drop-shadow(0 0 30px rgba(77, 212, 255, 0.5)) !important;
  font-weight: 700 !important;
  letter-spacing: 2px !important;
}

.modal-power-snapshot {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.6),
    rgba(10, 14, 39, 0.6)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.4) !important;
  border-radius: 20px !important;
  padding: 2rem !important;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset !important;
  backdrop-filter: blur(15px) !important;
}

.modal-power-snapshot h3 {
  font-size: 1.6rem !important;
  filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.4)) !important;
  font-weight: 700 !important;
  letter-spacing: 2px !important;
}

.modal-detail-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.5),
    rgba(10, 14, 39, 0.5)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.3) !important;
  border-radius: 18px !important;
  padding: 1.8rem !important;
  box-shadow:
    0 6px 25px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset !important;
  backdrop-filter: blur(10px) !important;
}

.modal-detail-section:hover {
  border-color: rgba(77, 212, 255, 0.5) !important;
  box-shadow:
    0 8px 30px rgba(77, 212, 255, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset !important;
  transform: translateY(-3px) !important;
}

.modal-detail-section h4 {
  font-size: 1.3rem !important;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.3)) !important;
  font-weight: 700 !important;
  letter-spacing: 1.5px !important;
}

/* Dependency Grid */
.dependency-grid span {
  padding: 0.5rem 0.9rem !important;
  font-size: 0.8rem !important;
  border-radius: 12px !important;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.2),
    rgba(77, 212, 255, 0.1)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.4) !important;
  font-weight: 600 !important;
  backdrop-filter: blur(10px) !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
}

.dependency-grid span:hover {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.35),
    rgba(77, 212, 255, 0.2)
  ) !important;
  transform: translateY(-3px) scale(1.08) !important;
  box-shadow: 0 6px 20px rgba(77, 212, 255, 0.4) !important;
}

/* Clear Filters Button */
.clear-filters-btn {
  padding: 1rem 1.5rem !important;
  border-radius: 14px !important;
  border: 2px solid rgba(255, 99, 71, 0.5) !important;
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.15),
    rgba(255, 99, 71, 0.08)
  ) !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(10px) !important;
  text-transform: uppercase !important;
  font-size: 0.9rem !important;
}

.clear-filters-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.35),
    rgba(255, 99, 71, 0.2)
  ) !important;
  border-color: rgba(255, 99, 71, 0.9) !important;
  transform: translateY(-3px) scale(1.05) !important;
  box-shadow: 0 10px 30px rgba(255, 99, 71, 0.4) !important;
}

/* Scroll to Top Button */
.scroll-to-top {
  width: 55px !important;
  height: 55px !important;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.95),
    rgba(77, 212, 255, 0.8)
  ) !important;
  border: 3px solid rgba(77, 212, 255, 0.6) !important;
  box-shadow: 0 6px 25px rgba(77, 212, 255, 0.4) !important;
  backdrop-filter: blur(15px) !important;
}

.scroll-to-top:hover {
  transform: translateY(-8px) scale(1.15) !important;
  box-shadow: 0 10px 35px rgba(77, 212, 255, 0.6) !important;
  background: linear-gradient(
    135deg,
    #4dd4ff,
    rgba(77, 212, 255, 0.95)
  ) !important;
}

/* Page Subtitle */
.page-subtitle {
  font-size: 1.15rem !important;
  line-height: 1.7 !important;
  color: rgba(232, 240, 255, 0.9) !important;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.4)) !important;
  font-weight: 500 !important;
}

/* Faction Summary */
.faction-summary {
  font-size: 1rem !important;
  line-height: 1.7 !important;
  color: rgba(232, 240, 255, 0.95) !important;
  padding-left: 1.2rem !important;
  border-left: 3px solid rgba(77, 212, 255, 0.4) !important;
  font-weight: 500 !important;
}

/* Modal Close Button */
.faction-modal .modal-close {
  width: 50px !important;
  height: 50px !important;
  background: linear-gradient(
    135deg,
    rgba(255, 87, 87, 0.2),
    rgba(255, 87, 87, 0.1)
  ) !important;
  border: 2px solid rgba(255, 87, 87, 0.4) !important;
  font-size: 1.6rem !important;
  backdrop-filter: blur(15px) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

.faction-modal .modal-close:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 87, 87, 0.4),
    rgba(255, 87, 87, 0.25)
  ) !important;
  border-color: #ff5757 !important;
  transform: rotate(90deg) scale(1.2) !important;
  box-shadow: 0 8px 30px rgba(255, 87, 87, 0.5) !important;
}

/* Impact Section */
.impact-section ul li {
  padding: 0.7rem 0.7rem 0.7rem 1.8rem !important;
  margin-bottom: 0.7rem !important;
  border-radius: 10px !important;
  font-weight: 500 !important;
  backdrop-filter: blur(5px) !important;
}

.impact-positive {
  border-left: 4px solid #90ee90 !important;
  background: linear-gradient(
    90deg,
    rgba(144, 238, 144, 0.1),
    transparent
  ) !important;
}

.impact-negative {
  border-left: 4px solid #ff6347 !important;
  background: linear-gradient(
    90deg,
    rgba(255, 99, 71, 0.1),
    transparent
  ) !important;
}

.impact-neutral {
  border-left: 4px solid #ffd700 !important;
  background: linear-gradient(
    90deg,
    rgba(255, 215, 0, 0.1),
    transparent
  ) !important;
}

/*  Grid Layout */
.factions-grid {
  gap: 2.5rem !important;
}

/*  Modal Power Bar */
.modal-power-bar {
  height: 14px !important;
  background: linear-gradient(
    90deg,
    rgba(10, 14, 39, 0.9),
    rgba(77, 212, 255, 0.2)
  ) !important;
  border-radius: 14px !important;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5) inset !important;
  border: 1px solid rgba(77, 212, 255, 0.3) !important;
}

.modal-power-bar div {
  background: linear-gradient(
    90deg,
    #4dd4ff 0%,
    #5de4ff 50%,
    #ffd700 100%
  ) !important;
  box-shadow:
    0 0 20px rgba(77, 212, 255, 0.9),
    0 0 40px rgba(77, 212, 255, 0.5) !important;
  border-radius: 14px !important;
}

/*  Modal Faction Summary */
.modal-faction-summary {
  font-size: 1.15rem !important;
  line-height: 1.8 !important;
  color: rgba(232, 240, 255, 0.95) !important;
  font-weight: 500 !important;
  padding: 1rem 1.5rem !important;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.05),
    transparent
  ) !important;
  border-left: 4px solid rgba(77, 212, 255, 0.4) !important;
  border-radius: 0 12px 12px 0 !important;
}

/*  Relations Section */
.relations-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.4),
    rgba(10, 14, 39, 0.4)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.3) !important;
  border-radius: 16px !important;
  padding: 1.5rem !important;
  backdrop-filter: blur(10px) !important;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3) !important;
}

/*  Timeline Section */
.timeline-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.6),
    rgba(10, 14, 39, 0.6)
  ) !important;
  border: 2px solid rgba(77, 212, 255, 0.4) !important;
  padding: 1.8rem !important;
  border-radius: 18px !important;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(10px) !important;
}

/* Mobile Enhancements */
@media (max-width: 767px) {
  .page-title {
    font-size: 2.5rem !important;
  }

  .faction-card {
    padding: 1.5rem !important;
  }

  .faction-card:hover {
    transform: none !important;
  }

  .modal-faction-title {
    font-size: 2rem !important;
  }

  .factions-controls {
    padding: 1.5rem !important;
  }
}

/* ===== ADDITIONAL VISUAL ENHANCEMENTS ===== */

/* Glassmorphism Effect for Cards */
.faction-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.05) 0%,
    transparent 50%,
    rgba(77, 212, 255, 0.05) 100%
  );
  border-radius: 24px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.faction-card:hover::after {
  opacity: 1;
}

/* Text Glow */
.faction-header h2::before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  filter: blur(20px);
  opacity: 0.5;
}

/* Particle Effect on Hover */
@keyframes particleFloat {
  0%,
  100% {
    transform: translateY(0) translateX(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
}

.faction-card:hover::before {
  animation: particleFloat 2s ease-in-out infinite;
}

/*  Focus States for Accessibility */
.expand-btn:focus-visible,
.factions-controls input:focus-visible,
.factions-controls select:focus-visible {
  outline: 3px solid rgba(77, 212, 255, 0.8) !important;
  outline-offset: 3px !important;
}

/* Smooth Page Transitions */
@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.factions-container {
  animation: pageEnter 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/*  Hover States for Interactive Elements */
.faction-card,
.expand-btn,
.factions-controls input,
.factions-controls select,
.relation,
.faction-link,
.timeline-node,
.dependency-grid span {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Typography */
.faction-header h2,
.page-title,
.modal-faction-title {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Contrast for Better Readability */
.faction-summary,
.page-subtitle,
.modal-faction-summary {
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Modal Backdrop */
.faction-modal {
  backdrop-filter: blur(12px) saturate(150%) !important;
  background: rgba(0, 0, 0, 0.9) !important;
}

/* Smooth Transitions for All Interactive Elements */
* {
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/*  Grid Responsiveness */
@media (min-width: 768px) and (max-width: 1024px) {
  .factions-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 2rem !important;
  }
}

@media (min-width: 1025px) {
  .factions-grid {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)) !important;
  }
}

/*  Scrollbar for Better UX */
.faction-modal .modal-body::-webkit-scrollbar {
  width: 10px !important;
}

.faction-modal .modal-body::-webkit-scrollbar-track {
  background: rgba(10, 14, 39, 0.6) !important;
  border-radius: 12px !important;
}

.faction-modal .modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4dd4ff, #ffd700) !important;
  border-radius: 12px !important;
  border: 2px solid rgba(10, 14, 39, 0.6) !important;
}

.faction-modal .modal-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffd700, #4dd4ff) !important;
  box-shadow: 0 0 10px rgba(77, 212, 255, 0.5) !important;
}

/*  No Results Message */
.no-results {
  padding: 4rem 2rem !important;
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.5),
    rgba(10, 14, 39, 0.5)
  ) !important;
  border: 2px dashed rgba(77, 212, 255, 0.3) !important;
  border-radius: 20px !important;
  backdrop-filter: blur(10px) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4) !important;
}

.no-results::before {
  font-size: 4rem !important;
  filter: drop-shadow(0 0 20px rgba(77, 212, 255, 0.3)) !important;
}

/*  Relation Border Indicators */
.faction-card[data-relation="allied"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #90ee90, transparent, #90ee90);
  border-radius: 24px 0 0 24px;
  box-shadow: 0 0 15px rgba(144, 238, 144, 0.5);
}

.faction-card[data-relation="hostile"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #ff6347, transparent, #ff6347);
  border-radius: 24px 0 0 24px;
  box-shadow: 0 0 15px rgba(255, 99, 71, 0.5);
}

.faction-card[data-relation="neutral"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(180deg, #ffd700, transparent, #ffd700);
  border-radius: 24px 0 0 24px;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/*  Power Item Labels */
.power-item span {
  position: relative;
  display: inline-block;
}

.power-item span::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, #4dd4ff, #ffd700);
  transition: width 0.3s ease;
}

.power-item:hover span::after {
  width: 100%;
}

/*  Modal Header Animation */
.modal-faction-header {
  position: relative;
  overflow: hidden;
}

.modal-faction-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(77, 212, 255, 0.1),
    transparent
  );
  animation: headerShine 3s ease-in-out infinite;
}

@keyframes headerShine {
  0% {
    left: -100%;
  }
  50%,
  100% {
    left: 100%;
  }
}

/*  Button Press Effect */
.expand-btn:active,
.clear-filters-btn:active {
  transform: translateY(-1px) scale(0.98) !important;
}

/*  Focus Indicators */
.faction-card:focus-within {
  outline: 3px solid rgba(77, 212, 255, 0.6);
  outline-offset: 4px;
}

/*  Faction Tag Hover Effects */
.faction-tag:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
}

/* Smooth Color Transitions */
.faction-card,
.expand-btn,
.relation,
.faction-link,
.timeline-node,
.dependency-grid span,
.faction-tag {
  transition:
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    background 0.3s ease,
    color 0.3s ease !important;
}

/*  Page Header */
.page-header {
  position: relative;
  padding-bottom: 2rem;
}

.page-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent,
    #4dd4ff,
    #ffd700,
    transparent
  );
  border-radius: 3px;
  box-shadow: 0 0 20px rgba(77, 212, 255, 0.5);
}

/* Performance Optimizations */
.faction-card,
.modal-content,
.factions-controls {
  contain: layout style paint;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High Contrast Mode Improvements */
@media (prefers-contrast: high) {
  .faction-card,
  .expand-btn,
  .factions-controls input,
  .factions-controls select {
    border-width: 3px !important;
  }

  .faction-header h2,
  .page-title {
    -webkit-text-fill-color: #4dd4ff !important;
  }
}

/* =====  UI IMPROVEMENTS ===== */
.faction-modal .modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: linear-gradient(
    135deg,
    rgba(255, 87, 87, 0.2),
    rgba(255, 87, 87, 0.1)
  );
  border: 2px solid rgba(255, 87, 87, 0.4);
  color: rgba(255, 255, 255, 0.95);
  font-size: 1.6rem;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 1020;
  backdrop-filter: blur(15px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  font-weight: bold;
}

.faction-modal .modal-close:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 87, 87, 0.4),
    rgba(255, 87, 87, 0.25)
  );
  border-color: #ff5757;
  color: #ff5757;
  transform: rotate(90deg) scale(1.2);
  box-shadow: 0 8px 30px rgba(255, 87, 87, 0.5);
}

/* power item labels */
.power-item span {
  font-weight: 700;
  color: rgba(232, 240, 255, 0.95);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-size: 0.85rem;
}

/*  faction header spacing */
.faction-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid rgba(77, 212, 255, 0.2);
  gap: 1rem;
  flex-wrap: wrap;
}

.timeline-node.active {
  opacity: 1;
  box-shadow: 0 0 20px rgba(77, 212, 255, 0.6);
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.2),
    rgba(77, 212, 255, 0.15)
  );
  border-color: rgba(77, 212, 255, 0.5);
}

/*  relation pills */
.relation {
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.3s ease;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/*  modal detail sections */
.modal-detail-section {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.5),
    rgba(10, 14, 39, 0.5)
  );
  border: 2px solid rgba(77, 212, 255, 0.3);
  border-radius: 18px;
  padding: 1.8rem;
  transition: all 0.3s ease;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.modal-detail-section:hover {
  border-color: rgba(77, 212, 255, 0.5);
  box-shadow: 0 8px 30px rgba(77, 212, 255, 0.2);
  transform: translateY(-3px);
}

/*  scroll to top button */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 55px;
  height: 55px;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.95),
    rgba(77, 212, 255, 0.8)
  );
  border: 2px solid rgba(77, 212, 255, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 6px 25px rgba(77, 212, 255, 0.4);
  backdrop-filter: blur(15px);
}

.scroll-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.scroll-to-top:hover {
  transform: translateY(-8px) scale(1.15);
  box-shadow: 0 10px 35px rgba(77, 212, 255, 0.6);
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 1),
    rgba(77, 212, 255, 0.95)
  );
}

.scroll-to-top::before {
  content: "↑";
  font-size: 1.8rem;
  color: #fff;
  font-weight: bold;
}

/*  clear filters button */
.clear-filters-btn {
  padding: 1rem 1.4rem;
  border-radius: 14px;
  border: 2px solid rgba(255, 99, 71, 0.5);
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.15),
    rgba(255, 99, 71, 0.08)
  );
  color: #ff6347;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  display: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.clear-filters-btn.visible {
  display: block;
}

.clear-filters-btn:hover {
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.3),
    rgba(255, 99, 71, 0.2)
  );
  border-color: rgba(255, 99, 71, 0.9);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 30px rgba(255, 99, 71, 0.4);
}

/*  no results message */
.no-results {
  text-align: center;
  padding: 4rem;
  color: rgba(232, 240, 255, 0.7);
  font-size: 1.3rem;
  font-family: "Cinzel", serif;
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.4),
    rgba(10, 14, 39, 0.4)
  );
  border-radius: 20px;
  border: 2px solid rgba(77, 212, 255, 0.2);
  backdrop-filter: blur(10px);
}

.no-results::before {
  content: "🔍";
  display: block;
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.6;
  animation: float 3s ease-in-out infinite;
}

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

/*  page header */
.page-header {
  text-align: center;
  margin-bottom: 3.5rem;
  position: relative;
  animation: fadeInDown 0.6s ease-out;
}

/*  faction tag glow effects */
.faction-tag.nation {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.25),
    rgba(77, 212, 255, 0.15)
  );
  color: #4dd4ff;
  border: 2px solid rgba(77, 212, 255, 0.4);
  position: relative;
  z-index: 1;
}

.faction-tag.council {
  background: linear-gradient(
    135deg,
    rgba(255, 215, 0, 0.25),
    rgba(255, 215, 0, 0.15)
  );
  color: #ffd700;
  border: 2px solid rgba(255, 215, 0, 0.4);
}

.faction-tag.military {
  background: linear-gradient(
    135deg,
    rgba(255, 99, 71, 0.25),
    rgba(255, 99, 71, 0.15)
  );
  color: #ff6347;
  border: 2px solid rgba(255, 99, 71, 0.4);
}

.faction-tag.guild {
  background: linear-gradient(
    135deg,
    rgba(144, 238, 144, 0.25),
    rgba(144, 238, 144, 0.15)
  );
  color: #90ee90;
  border: 2px solid rgba(144, 238, 144, 0.4);
}

.faction-tag.race {
  background: linear-gradient(
    135deg,
    rgba(186, 85, 211, 0.25),
    rgba(186, 85, 211, 0.15)
  );
  color: #ba55d3;
  border: 2px solid rgba(186, 85, 211, 0.4);
}

/*  modal power snapshot */
.modal-power-snapshot {
  background: linear-gradient(
    135deg,
    rgba(21, 27, 61, 0.6),
    rgba(10, 14, 39, 0.6)
  );
  border: 2px solid rgba(77, 212, 255, 0.4);
  border-radius: 18px;
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(15px);
}

.modal-power-snapshot h3 {
  color: #ffd700;
  font-family: "Cinzel", serif;
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
  text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  letter-spacing: 1.5px;
  font-weight: 700;
}

/*  dependency grid */
.dependency-grid span {
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.18),
    rgba(77, 212, 255, 0.12)
  );
  border: 2px solid rgba(77, 212, 255, 0.35);
  color: var(--text-light);
  transition: all 0.3s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.dependency-grid span:hover {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.3),
    rgba(77, 212, 255, 0.2)
  );
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 6px 20px rgba(77, 212, 255, 0.4);
  border-color: rgba(77, 212, 255, 0.6);
}

/*  search input icon */
.factions-controls input[type="text"] {
  min-width: 280px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="%234dd4ff" viewBox="0 0 16 16"><path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: 14px center;
  padding-left: 3rem;
}

/*  select dropdown */
.factions-controls select {
  cursor: pointer;
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="%234dd4ff" viewBox="0 0 16 16"><path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/></svg>');
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) center;
  padding-right: 3rem;
}

/*  modal header */
.modal-faction-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid rgba(77, 212, 255, 0.4);
  position: relative;
}

.modal-faction-header::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent,
    #4dd4ff,
    #ffd700,
    transparent
  );
  animation: headerGlow 3s ease-in-out infinite;
}

/*  faction links */
.faction-link {
  padding: 0.6rem 1.1rem;
  border-radius: 16px;
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.18),
    rgba(77, 212, 255, 0.08)
  );
  border: 2px solid rgba(77, 212, 255, 0.35);
  color: #4dd4ff;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.faction-link:hover {
  background: linear-gradient(
    135deg,
    rgba(77, 212, 255, 0.35),
    rgba(77, 212, 255, 0.2)
  );
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 6px 20px rgba(77, 212, 255, 0.4);
  border-color: rgba(77, 212, 255, 0.7);
}

/* ===== END OF  UI IMPROVEMENTS ===== */

/* ===== FINAL POLISH & ANIMATIONS ===== */

/* Staggered Card Entrance Animation */
.faction-card {
  animation: cardEntrance 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards !important;
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/*  Hover Lift Effect */
.faction-card {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.faction-card:hover {
  animation: none !important;
}

/* Ripple Effect on Click */
@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 1;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

.expand-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition:
    width 0.6s,
    height 0.6s;
}

.expand-btn:active::after {
  width: 300px;
  height: 300px;
  opacity: 0;
  transition: 0s;
}

/* Floating Animation for Tags */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.faction-tag {
  animation: float 3s ease-in-out infinite;
}

.faction-tag:nth-child(2) {
  animation-delay: 0.5s;
}

/* Glow Pulse for Active Elements */
@keyframes glowPulse {
  0%,
  100% {
    box-shadow: 0 0 20px rgba(77, 212, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(77, 212, 255, 0.6);
  }
}

.faction-card:focus-within {
  animation: glowPulse 2s ease-in-out infinite;
}

/* Smooth Fade-in for Modal Content */
.modal-detail-section {
  animation: modalContentFade 0.5s ease-out backwards;
}

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

.modal-detail-section:nth-child(1) {
  animation-delay: 0.1s;
}
.modal-detail-section:nth-child(2) {
  animation-delay: 0.15s;
}
.modal-detail-section:nth-child(3) {
  animation-delay: 0.2s;
}
.modal-detail-section:nth-child(4) {
  animation-delay: 0.25s;
}
.modal-detail-section:nth-child(5) {
  animation-delay: 0.3s;
}
.modal-detail-section:nth-child(6) {
  animation-delay: 0.35s;
}

/*  Search Input Animation */
.factions-controls input {
  position: relative;
}

.factions-controls input:focus {
  animation: inputFocusPulse 0.5s ease-out;
}

@keyframes inputFocusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(77, 212, 255, 0.7);
  }
  100% {
    box-shadow: 0 0 0 20px rgba(77, 212, 255, 0);
  }
}

/* Smooth Scroll Behavior */
html {
  scroll-behavior: smooth;
}

/*  Power Bar Fill Animation */
.power-bar div {
  transform-origin: left;
  animation: powerBarFill 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

@keyframes powerBarFill {
  from {
    width: 0 !important;
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.power-item:nth-child(1) .power-bar div {
  animation-delay: 0.1s;
}
.power-item:nth-child(2) .power-bar div {
  animation-delay: 0.2s;
}
.power-item:nth-child(3) .power-bar div {
  animation-delay: 0.3s;
}
.power-item:nth-child(4) .power-bar div {
  animation-delay: 0.4s;
}

/*  Mobile Touch Feedback */
@media (max-width: 767px) {
  .faction-card:active {
    transform: scale(0.98) !important;
    transition: transform 0.1s ease !important;
  }

  .expand-btn:active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
  }

  .faction-card:hover {
    transform: none !important;
    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.5),
      0 0 0 1px rgba(255, 255, 255, 0.08) inset,
      0 8px 32px rgba(77, 212, 255, 0.15) !important;
  }

  /* Optimize animations for mobile performance */
  .faction-card,
  .expand-btn,
  .power-bar div {
    animation-duration: 0.3s !important;
  }
}

/*  Skeleton Loading State */
.faction-card.loading {
  pointer-events: none;
  position: relative;
  overflow: hidden;
}

.faction-card.loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(77, 212, 255, 0.2),
    transparent
  );
  animation: skeletonLoading 1.5s infinite;
}

@keyframes skeletonLoading {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/*  Accessibility - Focus Visible */
.faction-card:focus-visible,
.expand-btn:focus-visible,
.relation:focus-visible,
.faction-link:focus-visible {
  outline: 3px solid #4dd4ff !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 6px rgba(77, 212, 255, 0.2) !important;
}

/*  Results Counter Animation */
.results-counter {
  animation: counterPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes counterPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Smooth Transition for Filtered Cards */
.faction-card {
  transition:
    opacity 0.4s ease,
    transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.3s ease,
    border-color 0.3s ease !important;
}

.faction-card.filtered-out {
  opacity: 0 !important;
  transform: scale(0.9) translateY(20px) !important;
  pointer-events: none !important;
}

.faction-card.filtered-in {
  animation: filterIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

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

/*  Modal Entrance */
.faction-modal.active {
  animation: modalBackdropFade 0.3s ease-out;
}

@keyframes modalBackdropFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.faction-modal.active .modal-content {
  animation: modalSlideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/*  Clear Button Animation */
.clear-filters-btn {
  animation: buttonSlideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes buttonSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/*  Scroll to Top Button */
.scroll-to-top {
  animation: scrollButtonFade 0.3s ease-out;
}

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

/* Subtle Background Pattern */
.factions-container::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(
      circle at 20% 50%,
      rgba(77, 212, 255, 0.03) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 80%,
      rgba(255, 215, 0, 0.03) 0%,
      transparent 50%
    );
  pointer-events: none;
  z-index: -1;
}

/*  Typography Hierarchy - glow effect already defined at top */

/*  Link Hover States */
.faction-link,
.relation {
  position: relative;
  overflow: hidden;
}

.faction-link::before,
.relation::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease;
}

.faction-link:hover::before,
.relation:hover::before {
  left: 100%;
}

/*  Grid Layout Animation */
.factions-grid {
  animation: gridFadeIn 0.8s ease-out 0.2s backwards;
}

@keyframes gridFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/*  No Results State */
.no-results {
  animation: noResultsBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes noResultsBounce {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  50% {
    transform: scale(1.05) translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Performance Optimization - GPU Acceleration */
.faction-card,
.expand-btn,
.modal-content,
.power-bar div,
.faction-tag,
.relation,
.faction-link {
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Smooth Opacity Transitions */
.faction-card,
.modal-detail-section,
.timeline-node,
.relation,
.faction-link {
  transition: opacity 0.3s ease;
}

/*  Visual Feedback */
.expand-btn:active,
.relation:active,
.faction-link:active,
.clear-filters-btn:active {
  transform: scale(0.95) !important;
  transition: transform 0.1s ease !important;
}

/*  Contrast for Better Readability */
.faction-header h2,
.page-title,
.modal-faction-title {
  text-shadow:
    0 2px 10px rgba(0, 0, 0, 0.5),
    0 0 30px rgba(77, 212, 255, 0.3);
}

/* Final Polish - Subtle Animations */
@keyframes subtleFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.faction-tag,
.relation {
  animation: subtleFloat 4s ease-in-out infinite;
}

/* Ensure Smooth Rendering */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
