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

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #2e3b48;
}

header {
  background-color: #2e3b48;
  color: white;
  text-align: center;
  padding: 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

header h1 {
  font-size: 28px;
  font-weight: 500;
}

main {
  min-height: calc(100vh - 140px);
}

.split-container {
  display: flex;
  flex-direction: row;
  min-height: calc(100vh - 140px);
}

.poem-section {
  flex: 1;
  background-color: #d4bc8c;
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.poem-content {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
  padding-right: 10px;
}

.poem-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.poem-content::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
  border-radius: 10px;
}

.poem-content::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
}

.poem-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

.poem-paragraph {
  margin-bottom: 30px;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease, color 0.3s ease, font-weight 0.3s ease;
  position: relative;
  z-index: 10;
  font-size: 2em;
  font-weight: 100;
  color: #444;
  padding: 10px;
  border-left: 3px solid transparent;
}

.poem-paragraph:hover {
  transform: translateX(5px);
  color: #111;
}

.poem-paragraph h2 {
  font-size: 1em;
  margin-bottom: 15px;
  font-weight: inherit;
  color: inherit;
}

.poem-paragraph p {
  font-size: 1em;
  margin-bottom: 8px;
  color: inherit;
}

.poem-paragraph.active {
  font-weight: 700;
  color: #000;
  transform: translateX(5px);
  border-left: 4px solid #3c4356;
  padding-left: 15px;
}

.poem-paragraph.dimmed {
  opacity: 0.6;
}

/* Enhanced visualization section with overflow control */
.visualization-section {
  flex: 1;
  background-color: #3c4356;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden !important;
  min-height: 650px;
  max-height: 850px;
}

/* Improved visibility for chart headings */
.vis-heading {
  color: #ffffff !important;
  text-align: center;
  margin-bottom: 20px;
  font-size: 22px;
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
}

/* Adjusted map container for better sizing */
.map-container {
  width: 100%;
  max-width: 700px;
  background-color: rgba(83, 103, 103, 0.7);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-height: 95% !important;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  overflow: hidden !important;
}

/* CONSISTENT CHART BACKGROUND */
.chart-background {
  fill: #2a3142 !important;
  rx: 8;
}

/* CONSISTENT LEGEND CONTAINER */
.legend-container {
  background-color: rgba(42, 49, 66, 0.9);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 15px;
  margin-top: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.map {
  width: 100%;
  height: 400px;
  background-color: rgba(44, 53, 71, 0.8);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.state {
  transition: opacity 0.3s;
}

.state:hover {
  opacity: 0.8;
  cursor: pointer;
}

/* Improved legend positioning */
.legend {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.legend-color-scale {
  height: 20px;
  width: 300px;
  margin-bottom: 8px;
  background: linear-gradient(to right, #e6f2ff, #0039a6);
  border-radius: 2px;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  width: 300px;
  font-size: 12px;
  color: #fff;
}

/* Enhanced tooltip with higher z-index */
.tooltip {
  position: absolute;
  background-color: rgba(42, 49, 66, 0.95);
  border-radius: 12px;
  padding: 15px;
  border-left: 4px solid #d4bc8c;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform-origin: top left;
  pointer-events: none;
  font-size: 14px;
  line-height: 1.5;
  max-width: 250px;
  z-index: 9999;
  display: none;
  color: white;
}

.tooltip strong {
  display: block;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 5px;
  color: white;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: rgba(255, 255, 255, 0.7);
  font-size: 16px;
}

.error {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  color: #ff6b6b;
  font-size: 16px;
  text-align: center;
  padding: 20px;
}

footer {
  background-color: #2e3b48;
  padding: 15px 0;
  display: flex;
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.navigation {
  display: flex;
  gap: 20px;
}

.navigation button {
  width: 40px;
  height: 40px;
  background-color: #d4bc8c;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  color: #333;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s;
}

.navigation button:hover {
  background-color: #c0a978;
}

/* Improved filter button styles with better spacing and margins */
.region-filter, .race-filter {
  padding: 10px 18px;
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
  margin: 3px !important;
}

.region-filter:hover, .race-filter:hover {
  background-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

.region-filter.active, .race-filter.active {
  background-color: #d4bc8c;
  color: #2a3142;
  border-color: #d4bc8c;
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(212, 188, 140, 0.4);
}

/* Filter container spacing with reduced margins */
.region-filters, .race-filters {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

@keyframes btn-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(212, 188, 140, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(212, 188, 140, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(212, 188, 140, 0);
  }
}

.btn-pulse {
  animation: btn-pulse 0.7s ease-out;
}

/* CONSISTENT CHART CONTAINERS */
.race-chart, .scatter-chart, .gender-chart-container {
  background-color: #2a3142 !important;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  margin-top: 15px;
  height: auto !important;
  min-height: 400px !important;
  max-height: 600px !important;
  position: relative;
  overflow: visible !important;
}

.gender-icon-grid {
  background-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 20px 0;
  gap: 5px;
}

.gender-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  width: 100%;
}

/* CONSISTENT STAT BOXES */
.stat-box {
  text-align: left;
  background-color: rgba(42, 49, 66, 0.9) !important;
  padding: 15px 20px;
  border-radius: 8px !important;
  min-width: 160px;
  flex-grow: 1;
  max-width: 200px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.stat-title {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
  font-weight: 600;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: white;
  margin-bottom: 6px;
}

.stat-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.stat-box.female {
  border-left: 5px solid #ff4d6d;
}

.stat-box.male {
  border-left: 5px solid #4361ee;
}

.stat-box.total {
  border-left: 5px solid #d4bc8c;
}

/* Gender icons */
.gender-icon {
  width: 16px;
  height: 32px;
  margin: 0 4px;
  transition: all 0.2s ease;
}

.gender-icon.female {
  filter: drop-shadow(0 0 3px rgba(255, 77, 109, 0.5));
}

.gender-icon.male {
  filter: drop-shadow(0 0 2px rgba(67, 97, 238, 0.3));
}

.gender-stats-row {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  width: 100%;
}

.gender-title {
  font-size: 22px;
  font-weight: 600;
  color: white;
  text-align: center;
  margin-bottom: 15px;
  margin-top: 5px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

.bar {
  transition: all 0.3s ease;
  cursor: pointer;
}

.bar:hover {
  filter: brightness(1.2);
  stroke-width: 2px !important;
}

/* Consistent chart labels */
.state-label, .axis-label {
  font-family: 'Helvetica Neue', Arial, sans-serif !important;
  fill: white !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7) !important;
}

.grid line {
  stroke: rgba(255, 255, 255, 0.1);
  stroke-dasharray: 3,3;
}

/* Enhanced styling for circle dots in scatter plot */
.circle-dot {
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.circle-dot:hover {
  stroke-width: 3px !important;
  transform: scale(1.05);
  filter: brightness(1.2) !important;
}

/* Consistent region indicator and axis notes */
.region-indicator, .axis-note {
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7) !important;
  opacity: 0.9 !important;
  font-weight: 700 !important;
  fill: white !important;
  font-size: 14px !important;
}

/* Consistent axes */
.x-axis text, .y-axis text {
  fill: rgba(255, 255, 255, 0.9) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
}

.x-axis path, .y-axis path {
  stroke: rgba(255, 255, 255, 0.5) !important;
}

.x-axis line, .y-axis line {
  stroke: rgba(255, 255, 255, 0.2) !important;
}

/* Make sure SVG doesn't get clipped */
svg {
  overflow: visible !important;
}

/* Responsive adjustments */
@media (max-height: 800px) {
  .visualization-section {
    min-height: 550px;
    max-height: 750px;
  }
  
  .race-chart, .scatter-chart, .gender-chart-container {
    min-height: 380px !important;
    max-height: 500px !important;
  }
  
  .poem-paragraph {
    margin-bottom: 20px;
    font-size: 1.8em;
  }
}

@media (max-width: 768px) {
  .split-container {
    flex-direction: column;
  }
  
  .poem-section, .visualization-section {
    width: 100%;
    min-height: 50vh;
  }
  
  .region-filters, .race-filters {
    flex-wrap: wrap;
  }
  
  .region-filter, .race-filter {
    padding: 8px 16px;
    font-size: 14px;
  }
  
  .map-container {
    padding: 15px;
  }
  
  .vis-heading, .map-container h2 {
    font-size: 18px;
  }
}