:root {
  --bg-color: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  
  --moth-clara: hsl(30, 15%, 80%);
  --moth-escura: hsl(30, 15%, 20%);
  
  /* Forest bark color controls: Light lichen to dark soot */
  --bark-lightness: 80%; 
  --bark-color: hsl(30, 15%, var(--bark-lightness));
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* --- Control Panel --- */
.control-panel {
  width: 320px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.header .subtitle {
  font-size: 0.9rem;
  color: var(--accent-color);
  font-style: italic;
  margin-top: 4px;
}

.glass-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
}

.instructions p {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.instructions strong {
  color: var(--text-main);
}

.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

input[type=range] {
  width: 100%;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.stats-group {
  display: flex;
  gap: 12px;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.population-group h3 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.progress-bar-container {
  display: flex;
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
  transition: all 0.3s ease;
}

.progress-clara {
  background-color: var(--moth-clara);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  transition: flex-grow 0.5s ease;
  white-space: nowrap;
}

.progress-escura {
  background-color: var(--moth-escura);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  transition: flex-grow 0.5s ease;
  white-space: nowrap;
}

.primary-btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: auto;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.primary-btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.6);
}

.primary-btn:disabled {
  background-color: #475569;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.mt-1 {
  margin-top: 1rem;
}

/* --- Forest Container --- */
.forest-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.forest {
  width: 100%;
  height: 100%;
  position: relative;
  /* Bark texture simulation */
  background-color: var(--bark-color);
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 10px, rgba(0,0,0,0.05) 10px, rgba(0,0,0,0.05) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0,0,0,0.03) 20px, rgba(0,0,0,0.03) 40px);
  transition: background-color 0.5s ease;
  /* Add noise for realistic bark */
  filter: contrast(1.1);
}

/* The Moths */
.moth {
  position: absolute;
  width: 40px;
  height: 30px;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.1s ease;
  /* Shape of a moth using polygon or SVG */
  clip-path: polygon(50% 0%, 100% 25%, 80% 75%, 50% 100%, 20% 75%, 0% 25%);
  /* A slightly more organic rotation happens inline via JS */
}

/* Moth patterns using CSS to look slightly textured */
.moth.clara {
  background: var(--moth-clara);
  background-image: radial-gradient(circle at 30% 30%, rgba(0,0,0,0.1) 1px, transparent 1px);
  background-size: 5px 5px;
}

.moth.escura {
  background: var(--moth-escura);
  background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 5px 5px;
}

.moth:hover {
  transform: scale(1.1) rotate(5deg) !important;
}

.moth.eaten {
  transform: scale(0) rotate(180deg) !important;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

/* --- Overlay --- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.overlay h2 {
  font-size: 2.5rem;
  margin-bottom: 16px;
}

.overlay p {
  font-size: 1.2rem;
  margin-bottom: 24px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}
