:root {
  --ink: #0f172a;
  --leaf: #16a34a;
  --ocean: #0891b2;
  --amber: #b45309;
  --coral: #db2777;
  --violet: #7c3aed;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  color: var(--ink);
  background: #06121a;
  overflow-x: hidden;
}
.app-root { position: relative; min-height: 100vh; }

/* background particles */
.bg-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particle {
  position: absolute; bottom: -40px; opacity: 0.35;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* header */
.evo-header {
  position: relative; z-index: 2; text-align: center;
  padding: 28px 16px 18px;
  background: radial-gradient(circle at 30% 0%, #134e4a 0%, #0b2e3a 45%, #071a26 100%);
  border-bottom: 3px solid rgba(255,255,255,0.06);
}
.header-glow {
  position: absolute; top: -60px; left: 50%; transform: translateX(-50%);
  width: 400px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(52,211,153,0.35), transparent 70%);
  filter: blur(20px); pointer-events: none;
}
.evo-title {
  position: relative; margin: 0 0 12px; font-weight: 900; font-size: clamp(26px, 6vw, 48px);
  background: linear-gradient(90deg, #34d399, #22d3ee, #f472b6, #fbbf24, #34d399);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shiftHue 8s linear infinite;
}
@keyframes shiftHue { to { background-position: 300% 0; } }
.fact-ribbon {
  display: inline-block; padding: 8px 22px; border-radius: 999px; font-weight: 700;
  color: #052e16; background: linear-gradient(90deg, #fde047, #86efac, #67e8f9);
  box-shadow: 0 6px 24px rgba(134,239,172,0.4); font-size: clamp(14px, 3vw, 18px);
  animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* nav */
.evo-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 9px 16px; border: none; border-radius: 14px; font-family: inherit;
  font-weight: 700; font-size: 14px; color: #e2e8f0;
  background: rgba(255,255,255,0.08); transition: all .2s;
}
.nav-tab:hover { transform: translateY(-2px); background: rgba(255,255,255,0.16); }
.nav-tab-active { color: #fff; transform: translateY(-2px); }
.nav-icon { font-size: 18px; }

/* main */
.evo-main {
  position: relative; z-index: 2; max-width: 1000px; margin: 0 auto;
  padding: 28px 16px 40px;
  animation: fadeSlide .5s ease both;
}
@keyframes fadeSlide { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.section-wrap {
  background: rgba(255,255,255,0.97); border-radius: 24px; padding: 26px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.section-h { margin: 0 0 6px; font-weight: 900; font-size: clamp(22px, 5vw, 34px); }
.section-lead { margin: 0 0 22px; color: #475569; line-height: 1.9; font-weight: 500; }

/* buttons */
.btn {
  cursor: pointer; border: none; border-radius: 12px; font-family: inherit;
  font-weight: 700; padding: 10px 18px; font-size: 14px; color: #fff;
  transition: transform .15s, filter .15s; margin: 3px;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn-green { background: linear-gradient(135deg, #22c55e, #15803d); }
.btn-purple { background: linear-gradient(135deg, #a855f7, #6d28d9); }
.btn-red { background: linear-gradient(135deg, #f87171, #dc2626); }
.btn-amber { background: linear-gradient(135deg, #fbbf24, #d97706); color: #431407; }
.btn-ghost { background: #e2e8f0; color: #334155; }

/* selection steps */
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.step-card {
  position: relative; padding: 22px 16px 18px; border-radius: 18px; text-align: center;
  background: linear-gradient(160deg, #ecfdf5, #d1fae5); border: 2px solid #a7f3d0;
  animation: popIn .5s ease both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
.step-num {
  position: absolute; top: -12px; right: 14px; width: 28px; height: 28px; border-radius: 50%;
  background: #16a34a; color: #fff; font-weight: 900; display: grid; place-items: center; font-size: 15px;
}
.step-icon { font-size: 40px; }
.step-title { margin: 6px 0 6px; font-weight: 800; color: #065f46; }
.step-desc { margin: 0; font-size: 13px; color: #047857; line-height: 1.7; }

.mini-demo { background: #f0fdf4; border: 2px dashed #86efac; border-radius: 18px; padding: 18px; }
.mini-demo-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.mini-demo-top h3 { margin: 0; color: #065f46; }
.mini-demo-hint { color: #059669; font-size: 13px; margin: 8px 0 14px; }
.critter-field { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.critter {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.15); animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* tree */
.tree-container {
  background: linear-gradient(160deg, #ecfeff, #f0fdfa); border-radius: 18px;
  padding: 18px; overflow-x: auto;
}
.tree-node { margin: 4px 0; }
.tree-row {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 14px; border-radius: 12px; border: 2px solid; font-weight: 700;
  transition: transform .15s, box-shadow .15s;
}
.tree-row:hover { transform: translateX(-4px); box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.tree-row-sel { box-shadow: 0 6px 18px rgba(0,0,0,0.16); }
.tree-toggle {
  width: 22px; height: 22px; border-radius: 6px; border: none; cursor: pointer;
  background: #0891b2; color: #fff; font-weight: 900; font-size: 15px; line-height: 1;
}
.tree-leaf-dot { color: #94a3b8; font-size: 20px; }
.tree-node-icon { font-size: 22px; }
.tree-node-name { font-size: 15px; }
.tree-popover {
  margin: 6px 30px 6px 0; padding: 10px 14px; border-radius: 12px; background: #fff;
  border: 2px solid; font-size: 13px; line-height: 1.8; color: #334155; max-width: 460px;
  animation: popIn .3s ease;
}
.tree-children { border-right: 2px dashed #a5f3fc; margin-right: 12px; padding-right: 6px; }

/* fossils */
.timeline-bar {
  display: flex; justify-content: space-between; margin-bottom: 18px; padding: 10px 6px;
  border-radius: 12px; background: linear-gradient(90deg, #7c3aed, #0891b2, #16a34a, #f59e0b, #ec4899, #ef4444);
}
.timeline-tick { color: #fff; font-weight: 800; font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.fossils-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.fossil-card { perspective: 1000px; cursor: pointer; height: 190px; }
.fossil-inner {
  position: relative; width: 100%; height: 100%; transition: transform .6s;
  transform-style: preserve-3d;
}
.fossil-flipped { transform: rotateY(180deg); }
.fossil-front, .fossil-back {
  position: absolute; inset: 0; backface-visibility: hidden; border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14px; text-align: center;
}
.fossil-front { color: #fff; box-shadow: 0 10px 26px rgba(0,0,0,0.25); }
.fossil-icon { font-size: 46px; }
.fossil-name { margin: 6px 0 2px; font-weight: 900; font-size: 17px; }
.fossil-en { font-size: 11px; opacity: 0.85; font-weight: 500; }
.fossil-flip-hint { margin-top: 10px; font-size: 11px; background: rgba(255,255,255,0.25); padding: 3px 10px; border-radius: 999px; }
.fossil-back { background: #fff; border: 3px solid; transform: rotateY(180deg); }
.fossil-age { font-weight: 900; font-size: 14px; margin-bottom: 8px; }
.fossil-fact { margin: 0; font-size: 12.5px; line-height: 1.8; color: #334155; }

/* examples */
.examples-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.example-card { background: #fff; border-radius: 18px; border-top: 5px solid; padding: 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.example-head { display: flex; align-items: center; gap: 8px; }
.example-icon { font-size: 30px; }
.example-title { margin: 0; font-weight: 900; font-size: 19px; }
.example-intro { color: #475569; font-size: 13px; line-height: 1.8; margin: 8px 0 14px; }
.morph-box { border-radius: 14px; padding: 20px; text-align: center; margin-bottom: 12px; }
.morph-emoji { font-size: 56px; transition: transform .4s, filter .4s; }
.morph-label { font-weight: 800; margin-top: 6px; }
.morph-desc { font-size: 12px; color: #475569; margin-top: 2px; }
.morph-slider { width: 100%; height: 6px; }
.morph-ends { display: flex; justify-content: space-between; font-size: 11px; color: #94a3b8; margin-top: 4px; font-weight: 600; }

/* simulator */
.sim-controls { margin-bottom: 14px; }
.env-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.env-btn {
  cursor: pointer; border: 2px solid #cbd5e1; border-radius: 12px; padding: 9px 16px;
  font-family: inherit; font-weight: 700; font-size: 13px; transition: all .15s;
}
.env-btn:hover { transform: translateY(-2px); }
.env-btn-active { border-color: transparent; box-shadow: 0 6px 16px rgba(0,0,0,0.2); }
.sim-canvas {
  width: 100%; border-radius: 18px; display: block; box-shadow: inset 0 0 0 3px rgba(0,0,0,0.06);
}
.sim-stats { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.stat-box { flex: 1; min-width: 120px; background: #f1f5f9; border-radius: 14px; padding: 12px; text-align: center; }
.stat-num { display: block; font-size: 30px; font-weight: 900; color: #7c3aed; }
.stat-lbl { font-size: 12px; color: #64748b; font-weight: 600; }
.fit-bar-bg { height: 22px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-bottom: 6px; }
.fit-bar { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f87171, #fbbf24, #34d399); transition: width .4s; }
.sim-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.speed-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #475569; margin-right: 8px; }

.win-banner {
  margin-top: 16px; padding: 18px; border-radius: 16px; text-align: center;
  background: linear-gradient(135deg, #fef08a, #86efac); border: 2px solid #22c55e;
  animation: popIn .5s ease;
}
.win-text { font-weight: 900; font-size: 18px; color: #14532d; margin-bottom: 10px; }
.saved-note { font-weight: 700; color: #15803d; }

.leaderboard { margin-top: 22px; background: #faf5ff; border: 2px solid #e9d5ff; border-radius: 16px; padding: 16px; }
.lb-title { margin: 0 0 12px; font-weight: 900; color: #6d28d9; }
.lb-empty { color: #a78bfa; font-size: 13px; }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-item { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.lb-rank { font-weight: 900; min-width: 24px; }
.lb-species { font-weight: 700; flex: 1; }
.lb-env { color: #64748b; font-size: 12px; }
.lb-gen { font-weight: 800; color: #7c3aed; }

/* footer */
.evo-footer {
  position: relative; z-index: 2; text-align: center; padding: 30px 16px 40px; color: #cbd5e1;
}
.footer-fact { font-weight: 800; font-size: 16px; margin: 0 0 6px;
  background: linear-gradient(90deg, #34d399, #67e8f9); -webkit-background-clip: text; background-clip: text; color: transparent; }
.footer-sub { font-size: 13px; opacity: 0.7; margin: 0 0 12px; }
.remix-link {
  display: inline-block; color: #fff; background: rgba(255,255,255,0.12);
  padding: 8px 20px; border-radius: 999px; text-decoration: none; font-weight: 700; font-size: 13px;
  transition: background .2s;
}
.remix-link:hover { background: rgba(255,255,255,0.24); }

@media (max-width: 640px) {
  .section-wrap { padding: 20px 14px; }
  .nav-tab { padding: 8px 12px; font-size: 13px; }
}