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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #050810;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: rgba(255,255,255,0.85);
}

canvas { display: block; width: 100vw; height: 100vh; }

#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #050810; z-index: 100; transition: opacity 0.5s ease;
}
#loading h1 {
  font-size: 2rem; font-weight: 300; letter-spacing: 0.35em;
  text-transform: uppercase; color: rgba(180,200,160,0.6); margin-bottom: 0.4rem;
}
#loading .subtitle {
  font-size: 0.75rem; color: rgba(180,200,160,0.25); letter-spacing: 0.12em; margin-bottom: 1.5rem;
}
.spinner {
  width: 34px; height: 34px;
  border: 2px solid rgba(180,200,160,0.12);
  border-top-color: rgba(180,200,160,0.5);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#ui {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 0.75rem;
  transition: opacity 0.3s ease; z-index: 10; pointer-events: none;
}
#ui > * { pointer-events: auto; }

.panel {
  background: rgba(10,15,22,0.7);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(180,200,160,0.08); border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.controls-panel { display: flex; flex-direction: column; gap: 0.5rem; min-width: 200px; }
.control-row { display: flex; align-items: center; gap: 0.5rem; }
.control-label {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(180,200,160,0.35); min-width: 38px;
}

.btn {
  background: rgba(180,200,160,0.06); border: 1px solid rgba(180,200,160,0.14);
  color: rgba(200,220,190,0.8); padding: 0.35rem 0.7rem; border-radius: 5px;
  font-size: 0.65rem; cursor: pointer; transition: all 0.2s ease;
  font-family: inherit; letter-spacing: 0.03em; flex: 1;
}
.btn:hover { background: rgba(180,200,160,0.14); border-color: rgba(180,200,160,0.3); }
.btn:active { transform: scale(0.96); }
.btn-group { display: flex; gap: 0.3rem; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  background: transparent; width: 100%; height: 16px; cursor: pointer;
}
input[type="range"]::-webkit-slider-track { height: 2px; background: rgba(180,200,160,0.12); border-radius: 1px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px;
  background: rgba(180,200,160,0.6); border-radius: 50%; margin-top: -4.5px;
}
input[type="range"]::-moz-range-track { height: 2px; background: rgba(180,200,160,0.12); border: none; }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; background: rgba(180,200,160,0.6); border-radius: 50%; border: none; }

.stats-panel { text-align: right; }
#stats {
  font-size: 0.65rem; font-family: 'JetBrains Mono', monospace;
  color: rgba(180,200,160,0.35); letter-spacing: 0.03em;
}

#status {
  position: fixed; top: 1.25rem; left: 50%; transform: translateX(-50%);
  font-size: 0.75rem; font-weight: 300; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(180,200,160,0.8);
  background: rgba(10,15,22,0.7); backdrop-filter: blur(10px);
  border: 1px solid rgba(180,200,160,0.1); padding: 0.4rem 1rem; border-radius: 6px;
  opacity: 0; z-index: 20; pointer-events: none;
}
#status.fade { animation: fadeToast 2s ease forwards; }
@keyframes fadeToast { 0%,70% { opacity:1; } 100% { opacity:0; } }

.title { position: fixed; top: 1rem; left: 1.25rem; z-index: 10; }
.title h1 { font-size: 0.9rem; font-weight: 300; letter-spacing: 0.25em; text-transform: uppercase; color: rgba(180,200,160,0.35); }
.title p { font-size: 0.55rem; color: rgba(180,200,160,0.18); letter-spacing: 0.08em; margin-top: 0.1rem; }

.help-hint {
  position: fixed; top: 1rem; right: 1.25rem;
  font-size: 0.55rem; color: rgba(180,200,160,0.18); letter-spacing: 0.03em;
  text-align: right; line-height: 1.5; z-index: 10;
}

.select-input {
  background: rgba(180,200,160,0.06); border: 1px solid rgba(180,200,160,0.14);
  color: rgba(200,220,190,0.8); padding: 0.3rem 0.5rem; border-radius: 5px;
  font-size: 0.65rem; cursor: pointer; font-family: inherit;
  letter-spacing: 0.03em; flex: 1; outline: none;
  -webkit-appearance: none; appearance: none;
}
.select-input:hover { background: rgba(180,200,160,0.14); border-color: rgba(180,200,160,0.3); }
.select-input option { background: #0a0f16; color: rgba(200,220,190,0.9); }

.seed-row { justify-content: space-between; }
.seed-value {
  font-family: 'JetBrains Mono', monospace; font-size: 0.6rem;
  color: rgba(180,200,160,0.45); cursor: pointer; letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem; border-radius: 4px;
  border: 1px solid transparent; transition: all 0.2s ease;
}
.seed-value:hover {
  color: rgba(180,200,160,0.7);
  border-color: rgba(180,200,160,0.2);
  background: rgba(180,200,160,0.06);
}

/* Help toggle link */
.help-toggle {
  display: inline-block; margin-top: 0.3rem;
  color: rgba(180,200,160,0.35); cursor: pointer;
  border: 1px solid rgba(180,200,160,0.12); border-radius: 4px;
  padding: 0.15rem 0.5rem; transition: all 0.2s ease;
  font-size: 0.55rem; letter-spacing: 0.05em;
}
.help-toggle:hover { color: rgba(180,200,160,0.7); border-color: rgba(180,200,160,0.3); background: rgba(180,200,160,0.06); }

/* Help overlay */
.help-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(3,5,10,0.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 2rem 1rem;
  animation: helpFadeIn 0.25s ease;
}
.help-overlay.hidden { display: none; }
@keyframes helpFadeIn { from { opacity: 0; } to { opacity: 1; } }

.help-content {
  max-width: 900px; width: 100%; position: relative;
  color: rgba(220,230,210,0.85);
}
.help-content h2 {
  font-size: 1.1rem; font-weight: 300; letter-spacing: 0.2em;
  text-transform: uppercase; color: rgba(180,200,160,0.6);
  margin-bottom: 0.5rem;
}
.help-intro {
  font-size: 0.75rem; color: rgba(180,200,160,0.45);
  line-height: 1.6; margin-bottom: 1.5rem; max-width: 700px;
}

.help-close {
  position: absolute; top: 0; right: 0;
  background: none; border: 1px solid rgba(180,200,160,0.15);
  color: rgba(180,200,160,0.5); font-size: 1.2rem;
  width: 32px; height: 32px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
}
.help-close:hover { color: rgba(180,200,160,0.9); border-color: rgba(180,200,160,0.4); background: rgba(180,200,160,0.08); }

.help-columns { display: flex; gap: 2.5rem; }
.help-col { flex: 1; min-width: 0; }

.help-content h3 {
  font-size: 0.7rem; font-weight: 400; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(180,200,160,0.5);
  margin: 1.25rem 0 0.5rem; padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(180,200,160,0.08);
}
.help-content h3:first-child { margin-top: 0; }

.help-content p { font-size: 0.68rem; line-height: 1.6; color: rgba(200,210,190,0.6); margin-bottom: 0.5rem; }
.help-content ul { list-style: none; padding: 0; margin: 0 0 0.5rem; }
.help-content li {
  font-size: 0.68rem; line-height: 1.5; color: rgba(200,210,190,0.55);
  padding: 0.15rem 0 0.15rem 0.8rem; position: relative;
}
.help-content li::before {
  content: ''; position: absolute; left: 0; top: 0.55rem;
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(180,200,160,0.2);
}
.help-content strong { color: rgba(220,230,210,0.8); font-weight: 400; }
.help-content code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.62rem;
  background: rgba(180,200,160,0.08); padding: 0.1rem 0.35rem;
  border-radius: 3px; color: rgba(180,200,160,0.6);
}

/* Particle type swatches */
.help-type { display: flex; gap: 0.6rem; margin-bottom: 0.6rem; align-items: flex-start; }
.help-swatch {
  width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; margin-top: 0.15rem;
  border: 1px solid rgba(255,255,255,0.1);
}
.help-type div { font-size: 0.68rem; line-height: 1.5; color: rgba(200,210,190,0.55); }
.help-type strong { color: rgba(220,230,210,0.8); font-weight: 400; }

.body-swatch { background: radial-gradient(circle, rgba(240,190,170,0.8), rgba(180,110,90,0.6)); }
.eye-swatch { background: radial-gradient(circle, #fff 40%, #3a7828 70%, #2a5518); }
.thruster-swatch { background: radial-gradient(circle, rgba(230,190,170,0.8), rgba(180,200,160,0.6)); border-radius: 50% 50% 30% 30%; }
.mouth-swatch { background: radial-gradient(circle, rgba(40,10,10,0.9) 40%, rgba(210,140,130,0.8)); }
.food-swatch { background: radial-gradient(circle, rgba(200,255,150,0.9), rgba(80,180,50,0.5)); }

/* Help table */
.help-table { width: 100%; border-collapse: collapse; margin: 0.3rem 0 0.5rem; }
.help-table td {
  font-size: 0.65rem; padding: 0.2rem 0.4rem;
  border-bottom: 1px solid rgba(180,200,160,0.05);
}
.help-table td:first-child {
  font-family: 'JetBrains Mono', monospace; color: rgba(180,200,160,0.5);
  white-space: nowrap; width: 70px;
}
.help-table td:last-child { color: rgba(200,210,190,0.5); }

@media (max-width: 768px) {
  #ui { padding: 0.6rem; flex-wrap: wrap; }
  .help-hint { display: none; }
  .help-columns { flex-direction: column; gap: 0; }
  .help-content { padding: 0 0.5rem; }
}
